2018-11-30 02:33:37 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-30 19:45:51 -05:00
|
|
|
When 'I visit {string}' do |string|
|
|
|
|
visit string
|
2018-11-30 18:22:10 -05:00
|
|
|
end
|
|
|
|
|
2018-12-02 17:20:16 -05:00
|
|
|
Then 'I am at {string}' do |re|
|
|
|
|
expect(page.current_path).to match(/\A#{re}\z/)
|
|
|
|
end
|
|
|
|
|
2018-11-30 18:22:10 -05:00
|
|
|
When 'I fill form with the following data:' do |table|
|
|
|
|
within 'form' do
|
|
|
|
table.rows.each do |(key, value)|
|
2018-12-01 19:38:43 -05:00
|
|
|
fill_in key, with: value, match: :prefer_exact
|
2018-11-30 18:22:10 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-02 17:20:16 -05:00
|
|
|
When 'I upload {string} as {string}' do |fixture, field|
|
|
|
|
within 'form' do
|
|
|
|
attach_file field, Rails.root.join('fixtures', fixture)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-01 19:38:43 -05:00
|
|
|
When 'I click the button {string}' do |string|
|
|
|
|
click_on string
|
|
|
|
end
|
|
|
|
|
2018-11-30 18:22:10 -05:00
|
|
|
When 'I click the form button {string}' do |string|
|
|
|
|
within 'form' do
|
|
|
|
click_on string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-04 21:12:23 -05:00
|
|
|
Then 'I see text {string}' do |text|
|
|
|
|
expect(page).to have_content text
|
|
|
|
end
|
|
|
|
|
2019-02-22 17:13:27 -05:00
|
|
|
Then 'I do not see text {string}' do |text|
|
|
|
|
expect(page).not_to have_content text
|
|
|
|
end
|
|
|
|
|
2018-12-12 15:00:16 -05:00
|
|
|
Then 'I see CSS {string} with text {string}' do |selector, text|
|
|
|
|
expect(page).to have_css selector, text: text
|
2018-11-30 02:33:37 -05:00
|
|
|
end
|
2018-11-30 05:32:26 -05:00
|
|
|
|
|
|
|
Given 'I want to create the following passport:' do |table|
|
|
|
|
@passport_attributes = table.rows.to_h
|
|
|
|
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['Код подразделения']
|
|
|
|
|
2018-12-12 18:56:14 -05:00
|
|
|
attach_file 'Изображения', Rails.root.join('fixtures', 'passport_image_1.jpg')
|
2018-11-30 05:32:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
When 'I click the passport creation button' do
|
|
|
|
click_on 'Создать Паспорт'
|
|
|
|
end
|
|
|
|
|
|
|
|
Then 'I see the passport page' do
|
2018-12-02 17:48:00 -05:00
|
|
|
@passport_attributes.each do |key, value|
|
|
|
|
case key
|
|
|
|
when 'Пол'
|
|
|
|
nil
|
|
|
|
when 'Серия', 'Номер'
|
|
|
|
expect(page).to have_field key, with: value.to_i
|
|
|
|
else
|
2018-12-12 19:32:17 -05:00
|
|
|
expect(page).to have_field key, with: value if value.present?
|
2018-12-02 17:48:00 -05:00
|
|
|
end
|
|
|
|
end
|
2018-11-30 05:32:26 -05:00
|
|
|
end
|