Repository: DFE-Digital/register-early-career-teachers-public
Pull request #361: Some RSpec linting fixes
Author: login: peterdavidhamilton
Labels: name: Housekeeping
description: Making the code a bit nicer or faster without changing the behaviour
Created: 2025-03-19T11:41:29Z | Merged: 2025-03-19T14:11:24Z



Diff:
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index d1997385f..3f950cb78 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -64,32 +64,6 @@ RSpec/AnyInstance:
     - 'spec/requests/appropriate_bodies/claim_an_ect/register_ect_spec.rb'
     - 'spec/wizards/application_wizard_step_spec.rb'
 
-# Offense count: 2
-# This cop supports unsafe autocorrection (--autocorrect-all).
-RSpec/BeEq:
-  Exclude:
-    - 'spec/wizards/schools/register_mentor_wizard/mentor_spec.rb'
-
-# Offense count: 13
-# This cop supports unsafe autocorrection (--autocorrect-all).
-RSpec/BeEql:
-  Exclude:
-    - 'spec/lib/dfe_sign_in/api_client_spec.rb'
-    - 'spec/services/sessions/users/appropriate_body_persona_spec.rb'
-    - 'spec/services/sessions/users/appropriate_body_user_spec.rb'
-    - 'spec/services/sessions/users/dfe_persona_spec.rb'
-    - 'spec/services/sessions/users/dfe_user_spec.rb'
-    - 'spec/services/sessions/users/school_persona_spec.rb'
-    - 'spec/services/sessions/users/school_user_spec.rb'
-
-# Offense count: 1
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: be, be_nil
-RSpec/BeNil:
-  Exclude:
-    - 'spec/helpers/environment_helper_spec.rb'
-
 # Offense count: 1
 # This cop supports safe autocorrection (--autocorrect).
 # Configuration parameters: NegatedMatcher.
@@ -124,30 +98,11 @@ RSpec/ContextWording:
 RSpec/DescribedClass:
   Enabled: false
 
-# Offense count: 1
-# This cop supports safe autocorrection (--autocorrect).
-RSpec/EmptyLineAfterExampleGroup:
-  Exclude:
-    - 'spec/helpers/teacher_helper_spec.rb'
-
 # Offense count: 52
 # This cop supports safe autocorrection (--autocorrect).
 RSpec/EmptyLineAfterFinalLet:
   Enabled: false
 
-# Offense count: 8
-# This cop supports safe autocorrection (--autocorrect).
-RSpec/EmptyLineAfterSubject:
-  Exclude:
-    - 'spec/models/event_spec.rb'
-    - 'spec/models/induction_period_spec.rb'
-    - 'spec/models/pending_induction_submission_spec.rb'
-    - 'spec/services/schools/check_early_roll_out_mentor_spec.rb'
-    - 'spec/services/teachers/full_name_parser_spec.rb'
-    - 'spec/services/teachers/induction_period_spec.rb'
-    - 'spec/services/teachers/induction_spec.rb'
-    - 'spec/services/teachers/terms_completed_spec.rb'
-
 # Offense count: 6
 # This cop supports safe autocorrection (--autocorrect).
 # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
@@ -233,20 +188,6 @@ RSpec/NoExpectationExample:
   Exclude:
     - 'spec/components/navigation/primary_navigation_component_spec.rb'
 
-# Offense count: 9
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: not_to, to_not
-RSpec/NotToNot:
-  Exclude:
-    - 'spec/helpers/environment_helper_spec.rb'
-    - 'spec/models/concerns/interval_spec.rb'
-    - 'spec/services/schools/register_ect_spec.rb'
-    - 'spec/services/schools/register_mentor_spec.rb'
-    - 'spec/validators/programme_type_validator_spec.rb'
-    - 'spec/validators/working_pattern_validator_spec.rb'
-    - 'spec/views/appropriate_bodies/claim_an_ect/check_ect/edit.html.erb_spec.rb'
-
 # Offense count: 1
 RSpec/PendingWithoutReason:
   Exclude:
diff --git a/spec/helpers/environment_helper_spec.rb b/spec/helpers/environment_helper_spec.rb
index b0af92819..8168e511f 100644
--- a/spec/helpers/environment_helper_spec.rb
+++ b/spec/helpers/environment_helper_spec.rb
@@ -12,7 +12,7 @@
 
   describe '#environment_specific_header_colour_class' do
     it('is nil when no colour is set (defaults to blue)') do
-      expect(environment_specific_header_colour_class).to be(nil)
+      expect(environment_specific_header_colour_class).to be_nil
     end
 
     context "when ENVIRONMENT_COLOUR is set to 'pink'" do
@@ -31,7 +31,7 @@
     end
 
     it 'has a govuk tag with no colour modifier' do
-      expect(subject).to_not match(/govuk-tag--\w+/)
+      expect(subject).not_to match(/govuk-tag--\w+/)
     end
 
     context 'when ENVIRONMENT_PHASE_BANNER_TAG is not set' do
diff --git a/spec/helpers/teacher_helper_spec.rb b/spec/helpers/teacher_helper_spec.rb
index 1900f22f8..8f8eda514 100644
--- a/spec/helpers/teacher_helper_spec.rb
+++ b/spec/helpers/teacher_helper_spec.rb
@@ -30,6 +30,7 @@
 
       it { expect(teacher_induction_start_date(teacher)).to eq(1.year.ago.to_date.to_fs(:govuk)) }
     end
+
     context 'when not training' do
       it { expect(teacher_induction_start_date(teacher)).to be_nil }
     end
diff --git a/spec/lib/dfe_sign_in/api_client_spec.rb b/spec/lib/dfe_sign_in/api_client_spec.rb
index f84d28630..f2afd9b5f 100644
--- a/spec/lib/dfe_sign_in/api_client_spec.rb
+++ b/spec/lib/dfe_sign_in/api_client_spec.rb
@@ -47,7 +47,7 @@
     it 'allows the timeout to be overridden' do
       api_client = DfESignIn::APIClient.new(timeout: 8)
 
-      expect(api_client.connection.options.timeout).to eql(8)
+      expect(api_client.connection.options.timeout).to be(8)
     end
 
     it 'constructs the JWT using the correct values' do
diff --git a/spec/models/concerns/interval_spec.rb b/spec/models/concerns/interval_spec.rb
index c2fd1c1ca..e1f9358a8 100644
--- a/spec/models/concerns/interval_spec.rb
+++ b/spec/models/concerns/interval_spec.rb
@@ -143,7 +143,7 @@
     context 'without overlapping sibling intervals' do
       before { DummyMentor.create(teacher_id:, school_id:, started_on: 1.week.ago, finished_on: 5.days.ago) }
 
-      it { is_expected.to_not have_overlap_with_siblings }
+      it { is_expected.not_to have_overlap_with_siblings }
     end
   end
 
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index ec307ead5..cfcfa537a 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -56,6 +56,7 @@
 
     describe '#event_happened_in_the_past' do
       subject { FactoryBot.build(:event, happened_at:) }
+
       before { subject.valid? }
 
       context 'when happened_at is in the past' do
diff --git a/spec/services/schools/check_early_roll_out_mentor_spec.rb b/spec/services/schools/check_early_roll_out_mentor_spec.rb
index 247d4975d..b70e8f735 100644
--- a/spec/services/schools/check_early_roll_out_mentor_spec.rb
+++ b/spec/services/schools/check_early_roll_out_mentor_spec.rb
@@ -1,5 +1,6 @@
 RSpec.describe Schools::CheckEarlyRollOutMentor do
   subject(:service) { described_class.new(trn) }
+
   let(:trn) { '7654321' }
 
   describe '#early_roll_out_mentor?' do
diff --git a/spec/services/schools/register_ect_spec.rb b/spec/services/schools/register_ect_spec.rb
index 3d6efbb6a..a645370a6 100644
--- a/spec/services/schools/register_ect_spec.rb
+++ b/spec/services/schools/register_ect_spec.rb
@@ -46,7 +46,7 @@
       let!(:teacher) { FactoryBot.create(:teacher, trn:) }
 
       it "doesn't create a new Teacher record" do
-        expect { service.register! }.to_not change(Teacher, :count)
+        expect { service.register! }.not_to change(Teacher, :count)
       end
     end
 
diff --git a/spec/services/schools/register_mentor_spec.rb b/spec/services/schools/register_mentor_spec.rb
index 4daa143d1..7846ec38b 100644
--- a/spec/services/schools/register_mentor_spec.rb
+++ b/spec/services/schools/register_mentor_spec.rb
@@ -42,7 +42,7 @@
       let!(:teacher) { FactoryBot.create(:teacher, trn:) }
 
       context "without MentorATSchoolPeriod records" do
-        it { expect { service.register! }.to_not change(Teacher, :count) }
+        it { expect { service.register! }.not_to change(Teacher, :count) }
       end
 
       context "with MentorATSchoolPeriod records" do
diff --git a/spec/services/sessions/users/appropriate_body_persona_spec.rb b/spec/services/sessions/users/appropriate_body_persona_spec.rb
index ae7e64f06..dd117a43a 100644
--- a/spec/services/sessions/users/appropriate_body_persona_spec.rb
+++ b/spec/services/sessions/users/appropriate_body_persona_spec.rb
@@ -17,13 +17,13 @@
 
   describe '.PROVIDER' do
     it 'returns :persona' do
-      expect(described_class::PROVIDER).to eql(:persona)
+      expect(described_class::PROVIDER).to be(:persona)
     end
   end
 
   describe '.USER_TYPE' do
     it 'returns :appropriate_body_user' do
-      expect(described_class::USER_TYPE).to eql(:appropriate_body_user)
+      expect(described_class::USER_TYPE).to be(:appropriate_body_user)
     end
   end
 
diff --git a/spec/services/sessions/users/appropriate_body_user_spec.rb b/spec/services/sessions/users/appropriate_body_user_spec.rb
index 2af53d2e8..69f0d6c1e 100644
--- a/spec/services/sessions/users/appropriate_body_user_spec.rb
+++ b/spec/services/sessions/users/appropriate_body_user_spec.rb
@@ -18,13 +18,13 @@
 
   describe '.PROVIDER' do
     it 'returns :dfe_sign_in' do
-      expect(described_class::PROVIDER).to eql(:dfe_sign_in)
+      expect(described_class::PROVIDER).to be(:dfe_sign_in)
     end
   end
 
   describe '.USER_TYPE' do
     it 'returns :appropriate_body_user' do
-      expect(described_class::USER_TYPE).to eql(:appropriate_body_user)
+      expect(described_class::USER_TYPE).to be(:appropriate_body_user)
     end
   end
 
diff --git a/spec/services/sessions/users/dfe_persona_spec.rb b/spec/services/sessions/users/dfe_persona_spec.rb
index daa39eb03..43fa46885 100644
--- a/spec/services/sessions/users/dfe_persona_spec.rb
+++ b/spec/services/sessions/users/dfe_persona_spec.rb
@@ -14,13 +14,13 @@
 
   describe '.PROVIDER' do
     it 'returns :persona' do
-      expect(described_class::PROVIDER).to eql(:persona)
+      expect(described_class::PROVIDER).to be(:persona)
     end
   end
 
   describe '.USER_TYPE' do
     it 'returns :dfe_staff_user' do
-      expect(described_class::USER_TYPE).to eql(:dfe_staff_user)
+      expect(described_class::USER_TYPE).to be(:dfe_staff_user)
     end
   end
 
diff --git a/spec/services/sessions/users/dfe_user_spec.rb b/spec/services/sessions/users/dfe_user_spec.rb
index 0bc30e4cd..c292ca597 100644
--- a/spec/services/sessions/users/dfe_user_spec.rb
+++ b/spec/services/sessions/users/dfe_user_spec.rb
@@ -14,13 +14,13 @@
 
   describe '.PROVIDER' do
     it 'returns :otp' do
-      expect(described_class::PROVIDER).to eql(:otp)
+      expect(described_class::PROVIDER).to be(:otp)
     end
   end
 
   describe '.USER_TYPE' do
     it 'returns :dfe_staff_user' do
-      expect(described_class::USER_TYPE).to eql(:dfe_staff_user)
+      expect(described_class::USER_TYPE).to be(:dfe_staff_user)
     end
   end
 
diff --git a/spec/services/sessions/users/school_persona_spec.rb b/spec/services/sessions/users/school_persona_spec.rb
index d95d49c8b..ffe27f7dc 100644
--- a/spec/services/sessions/users/school_persona_spec.rb
+++ b/spec/services/sessions/users/school_persona_spec.rb
@@ -14,13 +14,13 @@
 
   describe '.PROVIDER' do
     it 'returns :persona' do
-      expect(described_class::PROVIDER).to eql(:persona)
+      expect(described_class::PROVIDER).to be(:persona)
     end
   end
 
   describe '.USER_TYPE' do
     it 'returns :school_user' do
-      expect(described_class::USER_TYPE).to eql(:school_user)
+      expect(described_class::USER_TYPE).to be(:school_user)
     end
   end
 
diff --git a/spec/services/sessions/users/school_user_spec.rb b/spec/services/sessions/users/school_user_spec.rb
index 850a04700..8db8df351 100644
--- a/spec/services/sessions/users/school_user_spec.rb
+++ b/spec/services/sessions/users/school_user_spec.rb
@@ -18,13 +18,13 @@
 
   describe '.PROVIDER' do
     it 'returns :dfe_sign_in' do
-      expect(described_class::PROVIDER).to eql(:dfe_sign_in)
+      expect(described_class::PROVIDER).to be(:dfe_sign_in)
     end
   end
 
   describe '.USER_TYPE' do
     it 'returns :school_user' do
-      expect(described_class::USER_TYPE).to eql(:school_user)
+      expect(described_class::USER_TYPE).to be(:school_user)
     end
   end
 
diff --git a/spec/services/teachers/full_name_parser_spec.rb b/spec/services/teachers/full_name_parser_spec.rb
index ed7101efb..dd4846391 100644
--- a/spec/services/teachers/full_name_parser_spec.rb
+++ b/spec/services/teachers/full_name_parser_spec.rb
@@ -1,5 +1,6 @@
 describe Teachers::FullNameParser do
   subject(:service) { described_class.new(full_name:) }
+
   let(:full_name) { "\t Mrs. Alison Walnut Curtains-Handbag (Maiden-name ) \n" }
 
   describe '#first_name' do
diff --git a/spec/services/teachers/induction_period_spec.rb b/spec/services/teachers/induction_period_spec.rb
index dd749a9a0..e9aa85260 100644
--- a/spec/services/teachers/induction_period_spec.rb
+++ b/spec/services/teachers/induction_period_spec.rb
@@ -1,5 +1,6 @@
 describe Teachers::InductionPeriod do
   subject(:service) { described_class.new(teacher) }
+
   let(:teacher) { FactoryBot.create(:teacher) }
 
   context '#induction_start_date' do
diff --git a/spec/services/teachers/induction_spec.rb b/spec/services/teachers/induction_spec.rb
index cfa4c76e4..513536362 100644
--- a/spec/services/teachers/induction_spec.rb
+++ b/spec/services/teachers/induction_spec.rb
@@ -1,5 +1,6 @@
 RSpec.describe Teachers::Induction do
   subject(:service) { described_class.new(teacher) }
+
   let(:teacher) { FactoryBot.create(:teacher) }
 
   describe "#current_induction_period" do
diff --git a/spec/services/teachers/terms_completed_spec.rb b/spec/services/teachers/terms_completed_spec.rb
index 31a503514..0ee0dc712 100644
--- a/spec/services/teachers/terms_completed_spec.rb
+++ b/spec/services/teachers/terms_completed_spec.rb
@@ -1,5 +1,6 @@
 describe Teachers::TermsCompleted do
   subject(:service) { described_class.new(teacher) }
+
   let(:teacher) { FactoryBot.create(:teacher) }
 
   describe '#formatted_terms_completed' do
diff --git a/spec/validators/programme_type_validator_spec.rb b/spec/validators/programme_type_validator_spec.rb
index 8fc1a8dfc..5d0fc846e 100644
--- a/spec/validators/programme_type_validator_spec.rb
+++ b/spec/validators/programme_type_validator_spec.rb
@@ -25,7 +25,7 @@
       let(:programme_type) { nil }
 
       it 'it adds an error' do
-        expect(subject).to_not be_valid
+        expect(subject).not_to be_valid
         expect(subject.errors[:programme_type]).to include("Select either 'Provider-led' or 'School-led' training")
       end
     end
@@ -34,7 +34,7 @@
       let(:programme_type) { 'Invalid-value' }
 
       it 'adds an error' do
-        expect(subject).to_not be_valid
+        expect(subject).not_to be_valid
         expect(subject.errors[:programme_type]).to include("'Invalid-value' is not a valid programme type")
       end
     end
diff --git a/spec/validators/working_pattern_validator_spec.rb b/spec/validators/working_pattern_validator_spec.rb
index 155b5edee..bcecd7765 100644
--- a/spec/validators/working_pattern_validator_spec.rb
+++ b/spec/validators/working_pattern_validator_spec.rb
@@ -25,7 +25,7 @@
       let(:working_pattern) { nil }
 
       it 'it adds an error' do
-        expect(subject).to_not be_valid
+        expect(subject).not_to be_valid
         expect(subject.errors[:working_pattern]).to include("Select if the ECT's working pattern is full or part time")
       end
     end
@@ -34,7 +34,7 @@
       let(:working_pattern) { 'Invalid-value' }
 
       it 'adds an error' do
-        expect(subject).to_not be_valid
+        expect(subject).not_to be_valid
         expect(subject.errors[:working_pattern]).to include("'Invalid-value' is not a valid working pattern")
       end
     end
diff --git a/spec/views/appropriate_bodies/claim_an_ect/check_ect/edit.html.erb_spec.rb b/spec/views/appropriate_bodies/claim_an_ect/check_ect/edit.html.erb_spec.rb
index 519215a08..cc376d12d 100644
--- a/spec/views/appropriate_bodies/claim_an_ect/check_ect/edit.html.erb_spec.rb
+++ b/spec/views/appropriate_bodies/claim_an_ect/check_ect/edit.html.erb_spec.rb
@@ -45,7 +45,7 @@
         render
         expect(rendered).to have_text('You cannot register Anna Chancellor')
         expect(rendered).to have_text('completing their induction with another appropriate body')
-        expect(rendered).to_not have_button('Claim induction')
+        expect(rendered).not_to have_button('Claim induction')
       end
     end
   end
diff --git a/spec/wizards/schools/register_mentor_wizard/mentor_spec.rb b/spec/wizards/schools/register_mentor_wizard/mentor_spec.rb
index b1a35cd98..8964c9809 100644
--- a/spec/wizards/schools/register_mentor_wizard/mentor_spec.rb
+++ b/spec/wizards/schools/register_mentor_wizard/mentor_spec.rb
@@ -21,7 +21,7 @@
       let!(:existing_mentor_record) { FactoryBot.create(:mentor_at_school_period, :active, school:, teacher:) }
 
       it 'returns true' do
-        expect(mentor.active_at_school?).to eq(true)
+        expect(mentor.active_at_school?).to be(true)
       end
     end
 
@@ -29,7 +29,7 @@
       let!(:existing_mentor_record) { FactoryBot.create(:mentor_at_school_period, school:, teacher:) }
 
       it 'returns false' do
-        expect(mentor.active_at_school?).to eq(false)
+        expect(mentor.active_at_school?).to be(false)
       end
     end
   end


Reviews:
user: login: avinhurry
body: 🚀 
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-19T14:08:21Z
user: login: peterdavidhamilton
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-19T14:56:38Z
user: login: avinhurry
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-19T14:59:42Z
user: login: peterdavidhamilton
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-19T15:01:27Z

Review comments:
diff_hunk: @@ -64,32 +64,6 @@ RSpec/AnyInstance:
     - 'spec/requests/appropriate_bodies/claim_an_ect/register_ect_spec.rb'
     - 'spec/wizards/application_wizard_step_spec.rb'
 
-# Offense count: 2
-# This cop supports unsafe autocorrection (--autocorrect-all).
-RSpec/BeEq:
path: .rubocop_todo.yml
user: login: avinhurry
body: Are there any plans to fix the offences in here? It would be nice to abide by the cops. 
created_at: 2025-03-19T14:07:22Z
author_association: CONTRIBUTOR
diff_hunk: @@ -64,32 +64,6 @@ RSpec/AnyInstance:
     - 'spec/requests/appropriate_bodies/claim_an_ect/register_ect_spec.rb'
     - 'spec/wizards/application_wizard_step_spec.rb'
 
-# Offense count: 2
-# This cop supports unsafe autocorrection (--autocorrect-all).
-RSpec/BeEq:
path: .rubocop_todo.yml
user: login: peterdavidhamilton
body: I plan to work my way through them. 
created_at: 2025-03-19T14:56:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -64,32 +64,6 @@ RSpec/AnyInstance:
     - 'spec/requests/appropriate_bodies/claim_an_ect/register_ect_spec.rb'
     - 'spec/wizards/application_wizard_step_spec.rb'
 
-# Offense count: 2
-# This cop supports unsafe autocorrection (--autocorrect-all).
-RSpec/BeEq:
path: .rubocop_todo.yml
user: login: avinhurry
body: Nice, I can help!
created_at: 2025-03-19T14:59:42Z
author_association: CONTRIBUTOR
diff_hunk: @@ -64,32 +64,6 @@ RSpec/AnyInstance:
     - 'spec/requests/appropriate_bodies/claim_an_ect/register_ect_spec.rb'
     - 'spec/wizards/application_wizard_step_spec.rb'
 
-# Offense count: 2
-# This cop supports unsafe autocorrection (--autocorrect-all).
-RSpec/BeEq:
path: .rubocop_todo.yml
user: login: peterdavidhamilton
body: Please, do. I thought we could do them in small relevant batches. 👍🏼 
created_at: 2025-03-19T15:01:27Z
author_association: CONTRIBUTOR

PR comments:
user: login: github-actions[bot]
created_at: 2025-03-19T11:45:38Z
body: Review app deployed to https://cpd-ec2-review-361-web.test.teacherservices.cloud
<!-- Sticky Pull Request Comment -->
author_association: NONE
user: login: github-actions[bot]
created_at: 2025-03-19T14:12:46Z
body: Review app ECF2 deployed to <https://ec2-review-361-web.test.teacherservices.cloud> was deleted
<!-- Sticky Pull Request Commentaks -->
author_association: NONE