Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require:
- rubocop-rails
- rubocop-rspec
- rubocop-performance
- rubocop-capybara
- ./lib/linters/i18n_helper_html_linter.rb
- ./lib/linters/analytics_event_name_linter.rb
- ./lib/linters/localized_validation_message_linter.rb
Expand Down Expand Up @@ -43,6 +44,9 @@ Bundler/DuplicatedGem:
Bundler/InsecureProtocolSource:
Enabled: true

Capybara/CurrentPathExpectation:
Enabled: true

Gemspec/DuplicatedAssignment:
Enabled: true

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ group :development, :test do
gem 'rubocop-performance', '~> 1.23.0', require: false
gem 'rubocop-rails', '~> 2.27.0', require: false
gem 'rubocop-rspec', '~> 3.2.0', require: false
gem 'rubocop-capybara', require: false
gem 'sqlite3', require: false
end

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ GEM
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.36.2)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-performance (1.23.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
Expand Down Expand Up @@ -853,6 +855,7 @@ DEPENDENCIES
rspec-retry
rspec_junit_formatter
rubocop (~> 1.69.1)
rubocop-capybara
rubocop-performance (~> 1.23.0)
rubocop-rails (~> 2.27.0)
rubocop-rspec (~> 3.2.0)
Expand Down
8 changes: 4 additions & 4 deletions spec/features/accessibility/idv_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
complete_welcome_step
complete_agreement_step

expect(current_path).to eq idv_how_to_verify_path
expect(page).to have_current_path idv_how_to_verify_path
expect(page).to have_unique_form_landmark_labels
expect_page_to_have_no_accessibility_violations(page)
end
Expand All @@ -28,7 +28,7 @@
sign_in_and_2fa_user

visit idv_cancel_path
expect(current_path).to eq idv_cancel_path
expect(page).to have_current_path idv_cancel_path
expect_page_to_have_no_accessibility_violations(page)

visit idv_path
Expand All @@ -37,7 +37,7 @@
fill_in t('idv.form.password'), with: Features::SessionHelper::VALID_PASSWORD
click_continue

expect(current_path).to eq idv_personal_key_path
expect(page).to have_current_path idv_personal_key_path
expect_page_to_have_no_accessibility_violations(page)
end

Expand All @@ -48,7 +48,7 @@
fill_in t('idv.form.password'), with: Features::SessionHelper::VALID_PASSWORD
click_continue

expect(current_path).to eq idv_personal_key_path
expect(page).to have_current_path idv_personal_key_path
expect_page_to_have_no_accessibility_violations(page)
end
end
Expand Down
18 changes: 9 additions & 9 deletions spec/features/accessibility/user_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
email = 'test@example.com'
sign_up_with(email)

expect(current_path).to eq(sign_up_verify_email_path)
expect(page).to have_current_path(sign_up_verify_email_path)
# We can't validate markup here, since markup validation requires a page reload when using the
# JS driver, but the sign up verify email path can only be visited once before redirecting to
# the account creation form. Instead, we validate markup separately with the non-JS driver.
Expand All @@ -18,7 +18,7 @@
email = 'test@example.com'
sign_up_with(email)

expect(current_path).to eq(sign_up_verify_email_path)
expect(page).to have_current_path(sign_up_verify_email_path)
expect(page).to have_valid_markup
end
end
Expand All @@ -28,14 +28,14 @@
create(:user, :unconfirmed)
confirm_last_user

expect(current_path).to eq(sign_up_enter_password_path)
expect(page).to have_current_path(sign_up_enter_password_path, ignore_query: true)
expect_page_to_have_no_accessibility_violations(page)
end

scenario 'invalid confirmation token' do
visit sign_up_create_email_confirmation_path(confirmation_token: '123456')

expect(current_path).to eq(sign_up_register_path)
expect(page).to have_current_path(sign_up_register_path)
expect(page).to have_content(t('errors.messages.confirmation_invalid_token'))
expect_page_to_have_no_accessibility_violations(page)
end
Expand All @@ -45,7 +45,7 @@
scenario 'two factor options page' do
sign_up_and_set_password

expect(current_path).to eq(authentication_methods_setup_path)
expect(page).to have_current_path(authentication_methods_setup_path)
expect_page_to_have_no_accessibility_violations(page)
phone_checkbox = page.find_field('two_factor_options_form_selection_phone', visible: :all)
expect(phone_checkbox).to have_name(
Expand All @@ -61,15 +61,15 @@
find("label[for='two_factor_options_form_selection_phone']").click
click_button t('forms.buttons.continue')

expect(current_path).to eq(phone_setup_path)
expect(page).to have_current_path(phone_setup_path)
expect_page_to_have_no_accessibility_violations(page)
end

scenario 'two factor auth page' do
user = create(:user, :fully_registered)
sign_in_before_2fa(user)

expect(current_path).to eq(login_two_factor_path(otp_delivery_preference: 'sms'))
expect(page).to have_current_path login_two_factor_path(otp_delivery_preference: 'sms')
expect_page_to_have_no_accessibility_violations(page)
end

Expand All @@ -79,7 +79,7 @@
sign_in_before_2fa(user)
visit login_two_factor_path(otp_delivery_preference: 'sms')

expect(current_path).to eq login_two_factor_path(otp_delivery_preference: 'sms')
expect(page).to have_current_path login_two_factor_path(otp_delivery_preference: 'sms')
expect_page_to_have_no_accessibility_violations(page)
end
end
Expand All @@ -90,7 +90,7 @@
sign_in_before_2fa(user)
visit login_two_factor_path(otp_delivery_preference: 'voice')

expect(current_path).to eq login_two_factor_path(otp_delivery_preference: 'voice')
expect(page).to have_current_path login_two_factor_path(otp_delivery_preference: 'voice')
expect_page_to_have_no_accessibility_violations(page)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/account/backup_codes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
let(:user) { create(:user, :with_backup_code) }

it 'the user is not prompted to set up another MFA upon login' do
expect(current_path).to eq account_two_factor_authentication_path
expect(page).to have_current_path account_two_factor_authentication_path
end
end
end
8 changes: 4 additions & 4 deletions spec/features/account_creation/completions_cancel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
select_2fa_option('backup_code')
click_continue

expect(current_path).to eq(sign_up_completed_path)
expect(page).to have_current_path(sign_up_completed_path)

click_on t('links.cancel')

expect(current_path).to eq(sign_up_completed_cancel_path)
expect(page).to have_current_path(sign_up_completed_cancel_path)
click_on t('login_cancel.keep_going')

expect(current_path).to eq(sign_up_completed_path)
expect(page).to have_current_path(sign_up_completed_path)
click_on t('links.cancel')

expect(current_path).to eq(sign_up_completed_cancel_path)
expect(page).to have_current_path(sign_up_completed_cancel_path)
click_on t('login_cancel.exit', app_name: APP_NAME)

expect(current_url).to start_with('http://localhost:7654/auth/result?error=access_denied')
Expand Down
14 changes: 10 additions & 4 deletions spec/features/event_disavowal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@

# We should be on the MFA screen because we logged in with the new password
expect(page).to have_content(t('two_factor_authentication.header_text'))
expect(page.current_path).to eq(login_two_factor_path(otp_delivery_preference: :sms))
expect(page).to have_current_path(
login_two_factor_path(otp_delivery_preference: :sms),
)
end

scenario 'disavowing an event with javascript enabled', :js do
Expand All @@ -194,8 +196,10 @@
end

def submit_prefilled_otp_code(user, delivery_preference)
expect(current_path)
.to eq login_two_factor_path(otp_delivery_preference: delivery_preference)
expect(page).to have_current_path(
login_two_factor_path(otp_delivery_preference: delivery_preference),
ignore_query: true,
)
fill_in('code', with: user.reload.direct_otp)
click_button t('forms.buttons.submit.default')
end
Expand Down Expand Up @@ -232,7 +236,9 @@ def disavow_last_action_and_reset_password
expect(page).to have_current_path(login_two_factor_piv_cac_path)
else
expect(page).to have_content(t('two_factor_authentication.header_text'))
expect(page.current_path).to eq(login_two_factor_path(otp_delivery_preference: :sms))
expect(page).to have_current_path(
login_two_factor_path(otp_delivery_preference: :sms),
)
end
end
end
18 changes: 9 additions & 9 deletions spec/features/idv/cancel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
click_link t('links.cancel')

expect(page).to have_content(t('idv.cancel.headings.prompt.standard'))
expect(current_path).to eq(idv_cancel_path)
expect(page).to have_current_path(idv_cancel_path, ignore_query: true)
expect(fake_analytics).to have_logged_event(
'IdV: cancellation visited',
hash_including(step: 'agreement'),
Expand All @@ -40,7 +40,7 @@

click_on(t('idv.cancel.actions.keep_going'))

expect(current_path).to eq(original_path)
expect(page).to have_current_path(original_path)
expect(fake_analytics).to have_logged_event(
'IdV: cancellation go back',
hash_including(step: 'agreement'),
Expand All @@ -51,7 +51,7 @@
click_link t('links.cancel')

expect(page).to have_content(t('idv.cancel.headings.prompt.standard'))
expect(current_path).to eq(idv_cancel_path)
expect(page).to have_current_path(idv_cancel_path, ignore_query: true)
expect(fake_analytics).to have_logged_event(
'IdV: cancellation visited',
hash_including(step: 'agreement'),
Expand All @@ -65,7 +65,7 @@

click_on t('idv.cancel.actions.start_over')

expect(current_path).to eq(idv_welcome_path)
expect(page).to have_current_path(idv_welcome_path)
expect(fake_analytics).to have_logged_event(
'IdV: start over',
hash_including(step: 'agreement'),
Expand All @@ -76,7 +76,7 @@
click_link t('links.cancel')

expect(page).to have_content(t('idv.cancel.headings.prompt.standard'))
expect(current_path).to eq(idv_cancel_path)
expect(page).to have_current_path(idv_cancel_path, ignore_query: true)
expect(fake_analytics).to have_logged_event(
'IdV: cancellation visited',
hash_including(step: 'agreement'),
Expand All @@ -90,15 +90,15 @@

click_spinner_button_and_wait t('idv.cancel.actions.account_page')

expect(current_path).to eq(account_path)
expect(page).to have_current_path(account_path)
expect(fake_analytics).to have_logged_event(
'IdV: cancellation confirmed',
hash_including(step: 'agreement'),
)

# After visiting /verify, expect to redirect to the first step in the IdV flow.
visit idv_path
expect(current_path).to eq(idv_welcome_path)
expect(page).to have_current_path(idv_welcome_path)
end

context 'when user has recorded proofing components' do
Expand Down Expand Up @@ -173,7 +173,7 @@
click_link t('links.cancel')

expect(page).to have_content(t('idv.cancel.headings.prompt.standard'))
expect(current_path).to eq(idv_cancel_path)
expect(page).to have_current_path(idv_cancel_path, ignore_query: true)
expect(fake_analytics).to have_logged_event(
'IdV: cancellation visited',
hash_including(step: 'agreement'),
Expand All @@ -194,7 +194,7 @@
)

start_idv_from_sp(sp)
expect(current_path).to eq(idv_welcome_path)
expect(page).to have_current_path(idv_welcome_path)
end
end
end
12 changes: 6 additions & 6 deletions spec/features/idv/confirm_start_over_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
complete_idv_steps_before_gpo_step
click_on t('idv.messages.gpo.start_over_link_text')

expect(current_path).to eq idv_confirm_start_over_before_letter_path
expect(page).to have_current_path idv_confirm_start_over_before_letter_path
expect(page).to have_content(t('idv.cancel.description.gpo.start_over_new_address'))
expect_step_indicator_current_step(t('step_indicator.flows.idv.verify_phone'))
expect(fake_analytics).to have_logged_event(:idv_gpo_confirm_start_over_before_letter_visited)
click_idv_continue

expect(current_path).to eq idv_welcome_path
expect(page).to have_current_path idv_welcome_path
end
end

Expand All @@ -50,19 +50,19 @@
end

it 'can cancel from confirmation screen' do
expect(current_path).to eq idv_verify_by_mail_enter_code_path
expect(page).to have_current_path idv_verify_by_mail_enter_code_path

click_on t('idv.gpo.address_accordion.title')
click_on t('idv.gpo.address_accordion.cta_link')

expect(current_path).to eq idv_confirm_start_over_path
expect(page).to have_current_path idv_confirm_start_over_path
expect(page).to have_content(t('idv.cancel.description.gpo.start_over'))
expect_step_indicator_current_step(t('step_indicator.flows.idv.verify_address'))
expect(fake_analytics).to have_logged_event('IdV: gpo confirm start over visited')

click_idv_continue

expect(current_path).to eq idv_welcome_path
expect(page).to have_current_path idv_welcome_path
end

it 'can return back to verify screen from confirm screen' do
Expand All @@ -71,7 +71,7 @@
click_on t('forms.buttons.back')

expect(fake_analytics).to have_logged_event('IdV: gpo confirm start over visited')
expect(current_path).to eq idv_verify_by_mail_enter_code_path
expect(page).to have_current_path idv_verify_by_mail_enter_code_path
end
end
end
8 changes: 4 additions & 4 deletions spec/features/idv/doc_auth/hybrid_handoff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
fill_in :doc_auth_phone, with: ''
click_send_link

expect(page).to have_current_path(idv_hybrid_handoff_path, ignore_query: true)
expect(page).to have_current_path(idv_hybrid_handoff_path)
end

it 'sends a link that does not contain any underscores' do
Expand All @@ -82,7 +82,7 @@

click_send_link

expect(page).to have_current_path(idv_hybrid_handoff_path, ignore_query: true)
expect(page).to have_current_path(idv_hybrid_handoff_path)
expect(page).to have_content I18n.t('telephony.error.friendly_message.generic')
end

Expand Down Expand Up @@ -136,7 +136,7 @@
fill_in :doc_auth_phone, with: '415-555-0199'

click_send_link
expect(page).to have_current_path(idv_hybrid_handoff_path, ignore_query: true)
expect(page).to have_current_path(idv_hybrid_handoff_path)
expect(page).to have_content(
I18n.t(
'doc_auth.errors.send_link_limited',
Expand Down Expand Up @@ -308,7 +308,7 @@ def verify_upload_photos_section_and_link(page)

click_link t('links.cancel')
expect(page).to have_content(t('idv.cancel.headings.prompt.standard'))
expect(current_path).to eq(idv_cancel_path)
expect(page).to have_current_path(idv_cancel_path, ignore_query: true)
end

def verify_no_upload_photos_section_and_link(page)
Expand Down
Loading