From 8c4e299ee5432e29b4d7fcf3ac192d1553231504 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 30 Nov 2018 15:32:26 +0500 Subject: [PATCH] Add feature "Passport creation" --- features/passport_creation.feature | 35 +++++++++++++++++++++++ features/step_definitions/stepdefs.rb | 40 +++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 features/passport_creation.feature diff --git a/features/passport_creation.feature b/features/passport_creation.feature new file mode 100644 index 0000000..6a3ac8d --- /dev/null +++ b/features/passport_creation.feature @@ -0,0 +1,35 @@ +Feature: Passport creation + Background: + Given I visit passport creation page + + Scenario: + Given I want to create the following passport: + | key | value | + | Фамилия | Иванов | + | Имя | Иван | + | Отчество | Иванович | + | Пол | Мужской | + | Место рождения | Москва | + | Серия | 1234 | + | Номер | 567890 | + | Кем выдан | ФСМ | + | Код подразделения | 123-456 | + When I fill the passport creation form + When I click the passport creation button + Then I see the passport page + + Scenario: + Given I want to create the following passport: + | key | value | + | Фамилия | Петрова | + | Имя | Мария | + | Отчество | | + | Пол | Женский | + | Место рождения | Мурманск | + | Серия | 0001 | + | Номер | 000001 | + | Кем выдан | ФСМ | + | Код подразделения | 001-001 | + When I fill the passport creation form + When I click the passport creation button + Then I see the passport page diff --git a/features/step_definitions/stepdefs.rb b/features/step_definitions/stepdefs.rb index 65a5c8e..8817361 100644 --- a/features/step_definitions/stepdefs.rb +++ b/features/step_definitions/stepdefs.rb @@ -15,3 +15,43 @@ Then 'I see main page' do text: I18n.translate('home.show.secondary_title'), ) end + +Given 'I want to create the following passport:' do |table| + @passport_attributes = table.rows.to_h +end + +When 'I visit passport creation page' do + visit '/passports/new' +end + +When 'I fill the passport creation form' do + fill_in 'Фамилия', with: @passport_attributes['Фамилия'] + fill_in 'Имя', with: @passport_attributes['Имя'] + fill_in 'Отчество', with: @passport_attributes['Отчество'] + + choose @passport_attributes['Пол'] + + fill_in 'Место рождения', with: @passport_attributes['Место рождения'] + fill_in 'Серия', with: @passport_attributes['Серия'] + fill_in 'Номер', with: @passport_attributes['Номер'] + fill_in 'Кем выдан', with: @passport_attributes['Кем выдан'] + fill_in 'Код подразделения', with: @passport_attributes['Код подразделения'] + + attach_file 'Изображение', 'fixtures/passport_image_1.jpg' +end + +When 'I click the passport creation button' do + click_on 'Создать Паспорт' +end + +Then 'I see the passport page' do + expect(page).to have_content @passport_attributes['Фамилия'] + expect(page).to have_content @passport_attributes['Имя'] + expect(page).to have_content @passport_attributes['Отчество'] + expect(page).to have_content @passport_attributes['Пол'] + expect(page).to have_content @passport_attributes['Место рождения'] + expect(page).to have_content @passport_attributes['Серия'] + expect(page).to have_content @passport_attributes['Номер'] + expect(page).to have_content @passport_attributes['Кем выдан'] + expect(page).to have_content @passport_attributes['Код подразделения'] +end