diff --git a/.rubocop.yml b/.rubocop.yml index eac7713ae..72ed8e6b4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,9 +23,14 @@ Rails/LexicallyScopedActionFilter: Rails/SaveBang: Enabled: false -RSpec/Capybara/FeatureMethods: - Exclude: - - spec/system/**/* +RSpec/Dialect: + PreferredMethods: + background: :before + scenario: :it + xscenario: :xit + given: :let + given!: :let! + feature: :describe RSpec/InstanceVariable: Exclude: diff --git a/Gemfile.lock b/Gemfile.lock index 4eafddb49..777a1a505 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -303,6 +303,8 @@ GEM net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) notifications-ruby-client (5.4.0) @@ -313,7 +315,7 @@ GEM os (1.1.4) pagy (6.5.0) parallel (1.24.0) - parser (3.3.0.5) + parser (3.3.4.2) ast (~> 2.4.1) racc patience_diff (1.2.0) @@ -426,7 +428,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.62.1) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -437,29 +439,26 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) rubocop (~> 1.41) - rubocop-govuk (4.15.0) - rubocop (= 1.62.1) - rubocop-ast (= 1.31.2) - rubocop-rails (= 2.24.0) + rubocop-govuk (5.0.2) + rubocop (= 1.64.1) + rubocop-ast (= 1.31.3) + rubocop-capybara (= 2.21.0) + rubocop-rails (= 2.25.1) rubocop-rake (= 0.6.0) - rubocop-rspec (= 2.27.1) - rubocop-rails (2.24.0) + rubocop-rspec (= 3.0.1) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.27.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-rspec (3.0.1) + rubocop (~> 1.61) ruby-progressbar (1.13.0) ruby-rc4 (0.1.5) ruby2_keywords (0.0.5) @@ -546,6 +545,7 @@ GEM zeitwerk (2.6.16) PLATFORMS + arm64-darwin-24 x86_64-linux DEPENDENCIES diff --git a/spec/forms/referrals/allegation_details/check_answers_form_spec.rb b/spec/forms/referrals/allegation_details/check_answers_form_spec.rb index 72c27d609..7bdc90132 100644 --- a/spec/forms/referrals/allegation_details/check_answers_form_spec.rb +++ b/spec/forms/referrals/allegation_details/check_answers_form_spec.rb @@ -12,7 +12,7 @@ context "with a valid value" do it "saves the value on the referral" do save - expect(referral.allegation_details_complete).to eq(false) + expect(referral.allegation_details_complete).to be(false) end end diff --git a/spec/forms/referrals/allegation_details/details_form_spec.rb b/spec/forms/referrals/allegation_details/details_form_spec.rb index f15c706ba..9700b76f7 100644 --- a/spec/forms/referrals/allegation_details/details_form_spec.rb +++ b/spec/forms/referrals/allegation_details/details_form_spec.rb @@ -63,7 +63,7 @@ end it "clears the allegation details" do - expect(referral.allegation_details).to be nil + expect(referral.allegation_details).to be_nil end end diff --git a/spec/forms/referrals/allegation_evidence/check_answers_form_spec.rb b/spec/forms/referrals/allegation_evidence/check_answers_form_spec.rb index 42058f5d6..61c1bf1a7 100644 --- a/spec/forms/referrals/allegation_evidence/check_answers_form_spec.rb +++ b/spec/forms/referrals/allegation_evidence/check_answers_form_spec.rb @@ -12,7 +12,7 @@ context "with a valid value" do it "saves the value on the referral" do save - expect(referral.evidence_details_complete).to eq(false) + expect(referral.evidence_details_complete).to be(false) end end diff --git a/spec/forms/referrals/allegation_evidence/start_form_spec.rb b/spec/forms/referrals/allegation_evidence/start_form_spec.rb index e95733c2e..ed83f7cb0 100644 --- a/spec/forms/referrals/allegation_evidence/start_form_spec.rb +++ b/spec/forms/referrals/allegation_evidence/start_form_spec.rb @@ -12,7 +12,7 @@ context "with a valid value" do it "saves the value on the referral" do save - expect(referral.has_evidence).to eq(false) + expect(referral.has_evidence).to be(false) end end diff --git a/spec/forms/referrals/allegation_previous_misconduct/detailed_account_form_spec.rb b/spec/forms/referrals/allegation_previous_misconduct/detailed_account_form_spec.rb index 40e4bb95e..a1c5c848e 100644 --- a/spec/forms/referrals/allegation_previous_misconduct/detailed_account_form_spec.rb +++ b/spec/forms/referrals/allegation_previous_misconduct/detailed_account_form_spec.rb @@ -93,7 +93,7 @@ it "updates details on the referral" do save - expect(referral.previous_misconduct_details).to be nil + expect(referral.previous_misconduct_details).to be_nil end end diff --git a/spec/forms/referrals/teacher_personal_details/age_form_spec.rb b/spec/forms/referrals/teacher_personal_details/age_form_spec.rb index 926e5c781..470bd98df 100644 --- a/spec/forms/referrals/teacher_personal_details/age_form_spec.rb +++ b/spec/forms/referrals/teacher_personal_details/age_form_spec.rb @@ -39,7 +39,7 @@ end it "saves the age_known value" do - expect(referral.age_known).to eq(false) + expect(referral.age_known).to be(false) end context "when the date of birth was previously set" do diff --git a/spec/forms/referrals/teacher_personal_details/check_answers_form_spec.rb b/spec/forms/referrals/teacher_personal_details/check_answers_form_spec.rb index 77ade6b45..3e5fcf434 100644 --- a/spec/forms/referrals/teacher_personal_details/check_answers_form_spec.rb +++ b/spec/forms/referrals/teacher_personal_details/check_answers_form_spec.rb @@ -12,7 +12,7 @@ context "with a valid value" do it "saves the value on the referral" do save - expect(referral.personal_details_complete).to eq(false) + expect(referral.personal_details_complete).to be(false) end end diff --git a/spec/forms/referrals/teacher_role/duties_form_spec.rb b/spec/forms/referrals/teacher_role/duties_form_spec.rb index a1d117d58..1890e12a2 100644 --- a/spec/forms/referrals/teacher_role/duties_form_spec.rb +++ b/spec/forms/referrals/teacher_role/duties_form_spec.rb @@ -51,7 +51,7 @@ end it "updates details on the referral" do - expect(referral.duties_details).to be nil + expect(referral.duties_details).to be_nil end end diff --git a/spec/helpers/file_size_helper_spec.rb b/spec/helpers/file_size_helper_spec.rb index a1adbf66e..8431d0f43 100644 --- a/spec/helpers/file_size_helper_spec.rb +++ b/spec/helpers/file_size_helper_spec.rb @@ -5,7 +5,7 @@ subject { file_size(attachment) } context "when called with an attachment" do - let(:attachment) { instance_double("ActiveStorage::Blob", byte_size: 33.6.kilobytes) } + let(:attachment) { instance_double(ActiveStorage::Blob, byte_size: 33.6.kilobytes) } it { is_expected.to eq "33.6KB" } end diff --git a/spec/lib/custom_attrs_spec.rb b/spec/lib/custom_attrs_spec.rb index e3c24256e..8cde32dcb 100644 --- a/spec/lib/custom_attrs_spec.rb +++ b/spec/lib/custom_attrs_spec.rb @@ -19,8 +19,8 @@ class TestClass context "when the class doesn't have a referral object" do it "returns nil" do - expect(email_known).to eq(nil) - expect(email_address).to eq(nil) + expect(email_known).to be_nil + expect(email_address).to be_nil end end @@ -30,7 +30,7 @@ class TestClass before { test_class.referral = referral } it "returns the referral's values" do - expect(email_known).to eq(true) + expect(email_known).to be(true) expect(email_address).to eq("test@example.com") end @@ -41,7 +41,7 @@ class TestClass end it "returns the referral's updated values" do - expect(email_known).to eq(false) + expect(email_known).to be(false) expect(email_address).to eq("example@test.com") end end @@ -54,8 +54,8 @@ class TestClass context "when the class doesn't have an organisation object" do it "returns nil" do - expect(name).to eq(nil) - expect(street_1).to eq(nil) + expect(name).to be_nil + expect(street_1).to be_nil end end @@ -90,8 +90,8 @@ class TestClass context "when the class doesn't have a referrer object" do it "returns nil" do - expect(first_name).to eq(nil) - expect(last_name).to eq(nil) + expect(first_name).to be_nil + expect(last_name).to be_nil end end @@ -125,7 +125,7 @@ class TestClass context "when the class doesn't have an eligibility_check object" do it "returns nil" do - expect(serious_misconduct).to eq(nil) + expect(serious_misconduct).to be_nil end end diff --git a/spec/lib/devise/otp_spec.rb b/spec/lib/devise/otp_spec.rb index e7d890e0a..d0aa9cbec 100644 --- a/spec/lib/devise/otp_spec.rb +++ b/spec/lib/devise/otp_spec.rb @@ -6,14 +6,14 @@ secret_key = ROTP::Base32.random submitted_otp = ROTP::HOTP.new(secret_key).at(0) - expect(described_class.valid?(secret_key, submitted_otp)).to eq true + expect(described_class.valid?(secret_key, submitted_otp)).to be true end it "returns false if the OTPs don't match" do secret_key = ROTP::Base32.random submitted_otp = "bad_guess" - expect(described_class.valid?(secret_key, submitted_otp)).to eq false + expect(described_class.valid?(secret_key, submitted_otp)).to be false end end end diff --git a/spec/lib/staff_http_basic_auth_strategy_spec.rb b/spec/lib/staff_http_basic_auth_strategy_spec.rb index 3201633f8..e68692749 100644 --- a/spec/lib/staff_http_basic_auth_strategy_spec.rb +++ b/spec/lib/staff_http_basic_auth_strategy_spec.rb @@ -11,24 +11,24 @@ context "with staff users" do before { create(:staff) } - it { is_expected.to eq(false) } + it { is_expected.to be(false) } end context "when feature is active" do before { FeatureFlags::FeatureFlag.activate(:staff_http_basic_auth) } - it { is_expected.to eq(true) } + it { is_expected.to be(true) } end context "when there are no staff users" do - it { is_expected.to eq(true) } + it { is_expected.to be(true) } end end describe "#store?" do subject(:store?) { staff_http_basic_auth_strategy.store? } - it { is_expected.to eq(false) } + it { is_expected.to be(false) } end describe "#authenticate!" do diff --git a/spec/models/section_spec.rb b/spec/models/section_spec.rb index c3d891e0e..6820aff36 100644 --- a/spec/models/section_spec.rb +++ b/spec/models/section_spec.rb @@ -64,16 +64,17 @@ def slug context "when the section is not started" do it "returns the start path" do - allow(section).to receive(:started?).and_return(false) - allow(section).to receive(:start_path).and_return(:start_path) + allow(section).to receive_messages(started?: false, start_path: :start_path) expect(path).to eq :start_path end end context "when the section is started" do it "returns the check answers path" do - allow(section).to receive(:started?).and_return(true) - allow(section).to receive(:check_answers_path).and_return(:check_answers_path) + allow(section).to receive_messages( + started?: true, + check_answers_path: :check_answers_path + ) expect(path).to eq :check_answers_path end diff --git a/spec/requests/rack_attack_initializer_spec.rb b/spec/requests/rack_attack_initializer_spec.rb index a0ff7ba51..d638beca9 100644 --- a/spec/requests/rack_attack_initializer_spec.rb +++ b/spec/requests/rack_attack_initializer_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe "Rack::Attack initializer", rack_attack: true do +RSpec.describe "Rack::Attack initializer", :rack_attack do before { FeatureFlags::FeatureFlag.activate(:service_open) } describe "limit_otp_emails throttle" do diff --git a/spec/system/smoke_spec.rb b/spec/system/smoke_spec.rb index e7b7b021d..2c67d7035 100644 --- a/spec/system/smoke_spec.rb +++ b/spec/system/smoke_spec.rb @@ -8,7 +8,7 @@ TEST_ENVIRONMENTS = "local dev test preprod review" -RSpec.describe "Smoke test", type: :system, js: true, smoke_test: true do +RSpec.describe "Smoke test", :js, :smoke_test, type: :system do it "works as expected" do when_i_visit_the_service then_it_loads_successfully