diff --git a/.rubocop.yml b/.rubocop.yml index aaaf961c2..66e3555f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -123,4 +123,7 @@ RSpec/LetSetup: Enabled: true RSpec/MessageChain: + Enabled: true + +RSpec/MessageExpectation: Enabled: true \ No newline at end of file diff --git a/spec/features/localization_spec.rb b/spec/features/localization_spec.rb index 2296aeb6c..d9470c653 100644 --- a/spec/features/localization_spec.rb +++ b/spec/features/localization_spec.rb @@ -34,7 +34,7 @@ feature 'Localization' do end scenario 'Locale switcher not present if only one locale' do - expect(I18n).to receive(:available_locales).and_return([:en]) + allow(I18n).to receive(:available_locales).and_return([:en]) visit '/' expect(page).to_not have_content('Language') diff --git a/spec/features/management/localization_spec.rb b/spec/features/management/localization_spec.rb index ba4d7f27f..4f00a23dd 100644 --- a/spec/features/management/localization_spec.rb +++ b/spec/features/management/localization_spec.rb @@ -39,10 +39,10 @@ feature 'Localization' do end scenario 'Locale switcher not present if only one locale' do - expect(I18n).to receive(:available_locales).and_return([:en]) + allow(I18n).to receive(:available_locales).and_return([:en]) visit management_root_path expect(page).to_not have_content('Language') expect(page).to_not have_css('div.locale') end -end \ No newline at end of file +end diff --git a/spec/lib/census_api_spec.rb b/spec/lib/census_api_spec.rb index 8e2be6301..06fb2bc53 100644 --- a/spec/lib/census_api_spec.rb +++ b/spec/lib/census_api_spec.rb @@ -46,7 +46,7 @@ describe CensusApi do it "returns the response for the first valid variant" do allow(api).to receive(:get_response_body).with(1, "00123456").and_return(invalid_body) allow(api).to receive(:get_response_body).with(1, "123456").and_return(invalid_body) - expect(api).to receive(:get_response_body).with(1, "0123456").and_return(valid_body) + allow(api).to receive(:get_response_body).with(1, "0123456").and_return(valid_body) response = api.call(1, "123456") @@ -55,9 +55,9 @@ describe CensusApi do end it "returns the last failed response" do - expect(api).to receive(:get_response_body).with(1, "00123456").and_return(invalid_body) - expect(api).to receive(:get_response_body).with(1, "123456").and_return(invalid_body) - expect(api).to receive(:get_response_body).with(1, "0123456").and_return(invalid_body) + allow(api).to receive(:get_response_body).with(1, "00123456").and_return(invalid_body) + allow(api).to receive(:get_response_body).with(1, "123456").and_return(invalid_body) + allow(api).to receive(:get_response_body).with(1, "0123456").and_return(invalid_body) response = api.call(1, "123456") expect(response).to_not be_valid diff --git a/spec/lib/local_census_spec.rb b/spec/lib/local_census_spec.rb index 074d11a4c..58132a706 100644 --- a/spec/lib/local_census_spec.rb +++ b/spec/lib/local_census_spec.rb @@ -34,7 +34,7 @@ describe LocalCensus do it "returns the response for the first valid variant" do allow(api).to receive(:get_record).with(1, "00123456").and_return(invalid_body) allow(api).to receive(:get_record).with(1, "123456").and_return(invalid_body) - expect(api).to receive(:get_record).with(1, "0123456").and_return(valid_body) + allow(api).to receive(:get_record).with(1, "0123456").and_return(valid_body) response = api.call(1, "123456") @@ -43,9 +43,9 @@ describe LocalCensus do end it "returns the last failed response" do - expect(api).to receive(:get_record).with(1, "00123456").and_return(invalid_body) - expect(api).to receive(:get_record).with(1, "123456").and_return(invalid_body) - expect(api).to receive(:get_record).with(1, "0123456").and_return(invalid_body) + allow(api).to receive(:get_record).with(1, "00123456").and_return(invalid_body) + allow(api).to receive(:get_record).with(1, "123456").and_return(invalid_body) + allow(api).to receive(:get_record).with(1, "0123456").and_return(invalid_body) response = api.call(1, "123456") expect(response).to_not be_valid diff --git a/spec/lib/manager_authenticator_spec.rb b/spec/lib/manager_authenticator_spec.rb index ab94d0a3a..8ca0c7a67 100644 --- a/spec/lib/manager_authenticator_spec.rb +++ b/spec/lib/manager_authenticator_spec.rb @@ -47,13 +47,13 @@ describe ManagerAuthenticator do it 'calls the verification user method' do message = { ub: {user_key: "31415926", date: "20151031135905"} } allow(authenticator).to receive(:application_authorized?).and_return(true) - expect(authenticator.send(:client)).to receive(:call).with(:get_status_user_data, message: message) + allow(authenticator.send(:client)).to receive(:call).with(:get_status_user_data, message: message) authenticator.auth end it 'calls the permissions check method' do allow(authenticator).to receive(:manager_exists?).and_return(true) - expect(authenticator.send(:client)).to receive(:call).with(:get_applications_user_list, message: { ub: {user_key: "31415926"} }) + allow(authenticator.send(:client)).to receive(:call).with(:get_applications_user_list, message: { ub: {user_key: "31415926"} }) authenticator.auth end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 85be0b4f4..014e8342f 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -23,7 +23,7 @@ describe Notification do describe "#for_render (scope)" do it "returns notifications including notifiable and user" do - expect(described_class).to receive(:includes).with(:notifiable).exactly(:once) + allow(described_class).to receive(:includes).with(:notifiable).exactly(:once) described_class.for_render end end diff --git a/spec/models/signature_spec.rb b/spec/models/signature_spec.rb index dfb7dd5bf..5133af6fe 100644 --- a/spec/models/signature_spec.rb +++ b/spec/models/signature_spec.rb @@ -185,7 +185,7 @@ describe Signature do it "calls assign_vote_to_user" do signature = create(:signature, document_number: "12345678Z") - expect(signature).to receive(:assign_vote_to_user) + allow(signature).to receive(:assign_vote_to_user) signature.verify end @@ -219,4 +219,4 @@ describe Signature do end -end \ No newline at end of file +end diff --git a/spec/models/verification/management/email_spec.rb b/spec/models/verification/management/email_spec.rb index e71376322..57019c1e8 100644 --- a/spec/models/verification/management/email_spec.rb +++ b/spec/models/verification/management/email_spec.rb @@ -39,9 +39,9 @@ describe Verification::Management::Email do mail = double(:mail) allow(validation).to receive(:user).and_return user - expect(mail).to receive(:deliver_later) - expect(Devise.token_generator).to receive(:generate).with(User, :email_verification_token).and_return(["1", "2"]) - expect(Mailer).to receive(:email_verification).with(user, user.email, "2", "1", "1234").and_return(mail) + allow(mail).to receive(:deliver_later) + allow(Devise.token_generator).to receive(:generate).with(User, :email_verification_token).and_return(["1", "2"]) + allow(Mailer).to receive(:email_verification).with(user, user.email, "2", "1", "1234").and_return(mail) validation.save