From a9f9b0097bc18b87c7fe6636a74ea135bab61dc0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 16 Feb 2024 02:52:57 -0500 Subject: [PATCH] Reduce `RSpec/MultipleExpectations` in captcha feature spec (#29226) --- spec/features/captcha_spec.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spec/features/captcha_spec.rb b/spec/features/captcha_spec.rb index 15c37eb463..06c823adf2 100644 --- a/spec/features/captcha_spec.rb +++ b/spec/features/captcha_spec.rb @@ -19,12 +19,10 @@ describe 'email confirmation flow when captcha is enabled' do # It presents the user with a captcha form expect(page).to have_title(I18n.t('auth.captcha_confirmation.title')) - # It does not confirm the user just yet - expect(user.reload.confirmed?).to be false - # It redirects to app and confirms user - click_on I18n.t('challenge.confirm') - expect(user.reload.confirmed?).to be true + expect { click_on I18n.t('challenge.confirm') } + .to change { user.reload.confirmed? }.from(false).to(true) + expect(page).to have_current_path(/\A#{client_app.confirmation_redirect_uri}/, url: true) # Browsers will generally reload the original page upon redirection @@ -32,8 +30,9 @@ describe 'email confirmation flow when captcha is enabled' do visit "/auth/confirmation?confirmation_token=#{user.confirmation_token}&redirect_to_app=true" # It presents a page with a link to the app callback - expect(page).to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io')) - expect(page).to have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri) + expect(page) + .to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io')) + .and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri) end end