diff --git a/Gemfile.lock b/Gemfile.lock index f280cf10b..a88961748 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -484,9 +484,10 @@ GEM rack (>= 1.1) rubocop (>= 1.75.0, < 2.0) rubocop-ast (>= 1.44.0, < 2.0) - rubocop-rspec (3.9.0) + rubocop-rspec (3.10.0) lint_roller (~> 1.1) - rubocop (~> 1.81) + regexp_parser (>= 2.0) + rubocop (~> 1.86, >= 1.86.2) rubocop-rspec_rails (2.32.0) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) diff --git a/spec/concepts/class_member/create_spec.rb b/spec/concepts/class_member/create_spec.rb index a4744dd98..de9081c70 100644 --- a/spec/concepts/class_member/create_spec.rb +++ b/spec/concepts/class_member/create_spec.rb @@ -83,7 +83,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school_class:, students:, teachers:) - expect(response[:error]).to match(/No valid school members provided/) + expect(response[:error]).to include('No valid school members provided') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/class_member/delete_spec.rb b/spec/concepts/class_member/delete_spec.rb index 3d87ff4fa..974c86eb5 100644 --- a/spec/concepts/class_member/delete_spec.rb +++ b/spec/concepts/class_member/delete_spec.rb @@ -33,7 +33,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school_class:, class_member_id:) - expect(response[:error]).to match(/does-not-exist/) + expect(response[:error]).to include('does-not-exist') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/feedback/create_spec.rb b/spec/concepts/feedback/create_spec.rb index d70a66d3a..0a1d5a11b 100644 --- a/spec/concepts/feedback/create_spec.rb +++ b/spec/concepts/feedback/create_spec.rb @@ -80,12 +80,12 @@ it 'returns the error message in the operation response' do response = described_class.call(feedback_params:) - expect(response[:error]).to match(/Error creating feedback/) + expect(response[:error]).to include('Error creating feedback') end it 'raises school project not found error when no school project' do response = described_class.call(feedback_params:) - expect(response[:error]).to match(/School project must exist/) + expect(response[:error]).to include('School project must exist') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/feedback/delete_spec.rb b/spec/concepts/feedback/delete_spec.rb index 4183a6473..72fe75768 100644 --- a/spec/concepts/feedback/delete_spec.rb +++ b/spec/concepts/feedback/delete_spec.rb @@ -34,7 +34,7 @@ it 'returns the error message in the operation response' do response = described_class.call(feedback_id:) - expect(response[:error]).to match(/does-not-exist/) + expect(response[:error]).to include('does-not-exist') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/lesson/create_copy_spec.rb b/spec/concepts/lesson/create_copy_spec.rb index e0bbaa95c..b4e4a70d0 100644 --- a/spec/concepts/lesson/create_copy_spec.rb +++ b/spec/concepts/lesson/create_copy_spec.rb @@ -199,7 +199,7 @@ it 'returns the error message in the operation response' do response = described_class.call(lesson:, lesson_params:) - expect(response[:error]).to match(/Error creating copy of lesson/) + expect(response[:error]).to include('Error creating copy of lesson') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/lesson/create_spec.rb b/spec/concepts/lesson/create_spec.rb index c9d6b073c..253aff556 100644 --- a/spec/concepts/lesson/create_spec.rb +++ b/spec/concepts/lesson/create_spec.rb @@ -113,7 +113,7 @@ it 'returns the error message in the operation response' do response = described_class.call(lesson_params:) - expect(response[:error]).to match(/Error creating lesson/) + expect(response[:error]).to include('Error creating lesson') end it 'sent the exception to Sentry' do @@ -151,7 +151,7 @@ it 'returns the error message in the operation response' do response = described_class.call(lesson_params:) - expect(response[:error]).to match(/Error creating lesson/) + expect(response[:error]).to include('Error creating lesson') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/lesson/update_spec.rb b/spec/concepts/lesson/update_spec.rb index fb1d6c5ee..5ba8eb477 100644 --- a/spec/concepts/lesson/update_spec.rb +++ b/spec/concepts/lesson/update_spec.rb @@ -57,7 +57,7 @@ it 'returns the error message in the operation response' do response = described_class.call(lesson:, lesson_params:) - expect(response[:error]).to match(/Error updating lesson/) + expect(response[:error]).to include('Error updating lesson') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/project/update_spec.rb b/spec/concepts/project/update_spec.rb index e30d0035e..153b68946 100644 --- a/spec/concepts/project/update_spec.rb +++ b/spec/concepts/project/update_spec.rb @@ -93,7 +93,7 @@ end it 'returns an error message' do - expect(update[:error]).to match(/Projects with instructions must belong to a school/) + expect(update[:error]).to include('Projects with instructions must belong to a school') end end diff --git a/spec/concepts/school/delete_spec.rb b/spec/concepts/school/delete_spec.rb index cdc102f85..ca3c67659 100644 --- a/spec/concepts/school/delete_spec.rb +++ b/spec/concepts/school/delete_spec.rb @@ -48,7 +48,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school_id:) - expect(response[:error]).to match(/does-not-exist/) + expect(response[:error]).to include('does-not-exist') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school/update_spec.rb b/spec/concepts/school/update_spec.rb index 74c77db5e..2a26ce26b 100644 --- a/spec/concepts/school/update_spec.rb +++ b/spec/concepts/school/update_spec.rb @@ -40,7 +40,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, school_params:) - expect(response[:error]).to match(/Error updating school/) + expect(response[:error]).to include('Error updating school') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_class/create_spec.rb b/spec/concepts/school_class/create_spec.rb index 4a16a84e3..6cafd927c 100644 --- a/spec/concepts/school_class/create_spec.rb +++ b/spec/concepts/school_class/create_spec.rb @@ -57,7 +57,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, school_class_params:, current_user: teacher) - expect(response[:error]).to match(/Error creating school class/) + expect(response[:error]).to include('Error creating school class') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_class/delete_spec.rb b/spec/concepts/school_class/delete_spec.rb index 347906f92..010e17718 100644 --- a/spec/concepts/school_class/delete_spec.rb +++ b/spec/concepts/school_class/delete_spec.rb @@ -44,7 +44,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, school_class_id:) - expect(response[:error]).to match(/does-not-exist/) + expect(response[:error]).to include('does-not-exist') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_class/update_spec.rb b/spec/concepts/school_class/update_spec.rb index 5ce9011ab..ecd7d298d 100644 --- a/spec/concepts/school_class/update_spec.rb +++ b/spec/concepts/school_class/update_spec.rb @@ -42,7 +42,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school_class:, school_class_params:) - expect(response[:error]).to match(/Error updating school/) + expect(response[:error]).to include('Error updating school') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_student/create_spec.rb b/spec/concepts/school_student/create_spec.rb index 202b3815b..8db329ac1 100644 --- a/spec/concepts/school_student/create_spec.rb +++ b/spec/concepts/school_student/create_spec.rb @@ -67,7 +67,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, school_student_params:, token:) - expect(response[:error]).to match(/username '' is invalid/) + expect(response[:error]).to include("username '' is invalid") end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_student/delete_spec.rb b/spec/concepts/school_student/delete_spec.rb index 32c26daba..a79285982 100644 --- a/spec/concepts/school_student/delete_spec.rb +++ b/spec/concepts/school_student/delete_spec.rb @@ -37,7 +37,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, student_id:, token:) - expect(response[:error]).to match(/Some API error/) + expect(response[:error]).to include('Some API error') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_student/list_spec.rb b/spec/concepts/school_student/list_spec.rb index 5015cd99e..fa2c3a3c7 100644 --- a/spec/concepts/school_student/list_spec.rb +++ b/spec/concepts/school_student/list_spec.rb @@ -107,7 +107,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, token:, student_ids:) - expect(response[:error]).to match(/Some API error/) + expect(response[:error]).to include('Some API error') end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_student/update_spec.rb b/spec/concepts/school_student/update_spec.rb index b24d0152c..a87b54bf0 100644 --- a/spec/concepts/school_student/update_spec.rb +++ b/spec/concepts/school_student/update_spec.rb @@ -58,7 +58,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, student_id:, school_student_params:, token:) - expect(response[:error]).to match(/username ' ' is invalid/) + expect(response[:error]).to include("username ' ' is invalid") end it 'sent the exception to Sentry' do diff --git a/spec/concepts/school_teacher/invite_spec.rb b/spec/concepts/school_teacher/invite_spec.rb index 31f851c3f..9fdd1ad58 100644 --- a/spec/concepts/school_teacher/invite_spec.rb +++ b/spec/concepts/school_teacher/invite_spec.rb @@ -41,7 +41,7 @@ it 'returns the error message in the operation response' do response = described_class.call(school:, school_teacher_params:, token:) - expect(response[:error]).to match(/Email address 'invalid' is invalid/) + expect(response[:error]).to include("Email address 'invalid' is invalid") end it 'sent the exception to Sentry' do diff --git a/spec/features/class_member/creating_a_batch_of_class_members_spec.rb b/spec/features/class_member/creating_a_batch_of_class_members_spec.rb index f5ad035ba..819d62120 100644 --- a/spec/features/class_member/creating_a_batch_of_class_members_spec.rb +++ b/spec/features/class_member/creating_a_batch_of_class_members_spec.rb @@ -137,7 +137,7 @@ post("/api/schools/#{school.id}/classes/#{school_class.id}/members/batch", headers:, params:) data = JSON.parse(response.body, symbolize_names: true) member_not_added = data.find { |result| result[:user_id] == existing_class_member_id && result[:success] == false } - expect(member_not_added[:error]).to match(/Student has already been taken/) + expect(member_not_added[:error]).to include('Student has already been taken') end it 'returns success result for members that could be added' do @@ -187,7 +187,7 @@ it 'returns the error message in the operation response' do post("/api/schools/#{school.id}/classes/#{school_class.id}/members/batch", headers:, params: invalid_params) data = JSON.parse(response.body, symbolize_names: true) - expect(data[:error]).to match(/No valid school members provided/) + expect(data[:error]).to include('No valid school members provided') end end diff --git a/spec/features/class_member/creating_a_class_member_spec.rb b/spec/features/class_member/creating_a_class_member_spec.rb index 52e672d88..04230818e 100644 --- a/spec/features/class_member/creating_a_class_member_spec.rb +++ b/spec/features/class_member/creating_a_class_member_spec.rb @@ -216,7 +216,7 @@ post("/api/schools/#{school.id}/classes/#{school_class.id}/members", headers:, params: invalid_params) data = JSON.parse(response.body, symbolize_names: true) - expect(data[:error]).to match(/No valid school members provided/) + expect(data[:error]).to include('No valid school members provided') end end diff --git a/spec/features/feedback/deleting_feedback_spec.rb b/spec/features/feedback/deleting_feedback_spec.rb index c442be724..00101c6da 100644 --- a/spec/features/feedback/deleting_feedback_spec.rb +++ b/spec/features/feedback/deleting_feedback_spec.rb @@ -45,7 +45,7 @@ it 'returns an error message' do data = JSON.parse(response.body, symbolize_names: true) - expect(data[:error]).to match(/Couldn't find Feedback with 'id'="invalid-id"/) + expect(data[:error]).to include("Couldn't find Feedback with 'id'=\"invalid-id\"") end end end diff --git a/spec/features/school_student/batch_deleting_school_students_spec.rb b/spec/features/school_student/batch_deleting_school_students_spec.rb index c8a6e42f9..76d2543d5 100644 --- a/spec/features/school_student/batch_deleting_school_students_spec.rb +++ b/spec/features/school_student/batch_deleting_school_students_spec.rb @@ -208,7 +208,7 @@ # First student should have error failed_result = json['results'].find { |r| r['user_id'] == student_1.id } - expect(failed_result['error']).to match(/StandardError: Profile API error/) + expect(failed_result['error']).to include('StandardError: Profile API error') # Second student should succeed success_result = json['results'].find { |r| r['user_id'] == student_2.id } diff --git a/spec/graphql/mutations/delete_project_mutation_spec.rb b/spec/graphql/mutations/delete_project_mutation_spec.rb index f48c95256..5611cc60d 100644 --- a/spec/graphql/mutations/delete_project_mutation_spec.rb +++ b/spec/graphql/mutations/delete_project_mutation_spec.rb @@ -56,7 +56,7 @@ let(:project_id) { 'dummy' } it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/not found/) + expect(result.dig('errors', 0, 'message')).to include('not found') end end @@ -67,7 +67,7 @@ end it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/not permitted/) + expect(result.dig('errors', 0, 'message')).to include('not permitted') end end @@ -79,7 +79,7 @@ end it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/Deletion failed/) + expect(result.dig('errors', 0, 'message')).to include('Deletion failed') end end end diff --git a/spec/graphql/mutations/remix_project_mutation_spec.rb b/spec/graphql/mutations/remix_project_mutation_spec.rb index 3116cd9a4..af0fa170b 100644 --- a/spec/graphql/mutations/remix_project_mutation_spec.rb +++ b/spec/graphql/mutations/remix_project_mutation_spec.rb @@ -37,7 +37,7 @@ end it 'returns "not permitted to create" error' do - expect(result.dig('errors', 0, 'message')).to match(/not permitted to create/) + expect(result.dig('errors', 0, 'message')).to include('not permitted to create') end end @@ -45,7 +45,7 @@ let(:project_id) { SecureRandom.uuid } it 'returns "not found" error' do - expect(result.dig('errors', 0, 'message')).to match(/not found/) + expect(result.dig('errors', 0, 'message')).to include('not found') end it 'does not create a project' do @@ -60,7 +60,7 @@ end it 'returns "not permitted to read" error' do - expect(result.dig('errors', 0, 'message')).to match(/not permitted to read/) + expect(result.dig('errors', 0, 'message')).to include('not permitted to read') end it 'does not create a project' do diff --git a/spec/graphql/mutations/update_component_mutation_spec.rb b/spec/graphql/mutations/update_component_mutation_spec.rb index 79e4b2c87..b3ed06764 100644 --- a/spec/graphql/mutations/update_component_mutation_spec.rb +++ b/spec/graphql/mutations/update_component_mutation_spec.rb @@ -73,7 +73,7 @@ let(:component_id) { 'dummy' } it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/not found/) + expect(result.dig('errors', 0, 'message')).to include('not found') end end @@ -84,7 +84,7 @@ end it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/not permitted/) + expect(result.dig('errors', 0, 'message')).to include('not permitted') end end @@ -96,7 +96,7 @@ end it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/An error message/) + expect(result.dig('errors', 0, 'message')).to include('An error message') end end end diff --git a/spec/graphql/mutations/update_project_mutation_spec.rb b/spec/graphql/mutations/update_project_mutation_spec.rb index f1baacc77..4acb18e1a 100644 --- a/spec/graphql/mutations/update_project_mutation_spec.rb +++ b/spec/graphql/mutations/update_project_mutation_spec.rb @@ -69,7 +69,7 @@ let(:project_id) { 'dummy' } it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/not found/) + expect(result.dig('errors', 0, 'message')).to include('not found') end end @@ -80,7 +80,7 @@ end it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/not permitted/) + expect(result.dig('errors', 0, 'message')).to include('not permitted') end end @@ -92,7 +92,7 @@ end it 'returns an error' do - expect(result.dig('errors', 0, 'message')).to match(/An error message/) + expect(result.dig('errors', 0, 'message')).to include('An error message') end end end diff --git a/spec/services/student_removal_service_spec.rb b/spec/services/student_removal_service_spec.rb index ec493d5c9..d649cbbf9 100644 --- a/spec/services/student_removal_service_spec.rb +++ b/spec/services/student_removal_service_spec.rb @@ -168,7 +168,7 @@ results = service.remove_students # Should have error in result - expect(results.first[:error]).to match(/Profile API failure/) + expect(results.first[:error]).to include('Profile API failure') # Database changes should have been rolled back expect(Project.exists?(project.id)).to be true @@ -181,7 +181,7 @@ it 'handles errors gracefully' do allow(ClassStudent).to receive(:joins).and_raise(StandardError, 'fail') results = service.remove_students - expect(results.first[:error]).to match(/StandardError: fail/) + expect(results.first[:error]).to include('StandardError: fail') end it 'continues processing other students after an error' do @@ -197,7 +197,7 @@ results = service.remove_students expect(results.length).to eq(2) - expect(results.first[:error]).to match(/StandardError/) + expect(results.first[:error]).to include('StandardError') # Second student should succeed expect(Role.where(user_id: second_student.id, school: school, role: :student)).not_to exist end