Enable RSpec/MessageExpectation cop & fix issues

There was 34 `allow` occurences and 17 `expect` occurences, so to be consistent `allow` form was chosen.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageExpectation
This commit is contained in:
Bertocq
2018-01-07 16:31:01 +01:00
parent 987b31d618
commit c4aa2d7093
9 changed files with 22 additions and 19 deletions

View File

@@ -123,4 +123,7 @@ RSpec/LetSetup:
Enabled: true Enabled: true
RSpec/MessageChain: RSpec/MessageChain:
Enabled: true
RSpec/MessageExpectation:
Enabled: true Enabled: true

View File

@@ -34,7 +34,7 @@ feature 'Localization' do
end end
scenario 'Locale switcher not present if only one locale' do 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 '/' visit '/'
expect(page).to_not have_content('Language') expect(page).to_not have_content('Language')

View File

@@ -39,10 +39,10 @@ feature 'Localization' do
end end
scenario 'Locale switcher not present if only one locale' do 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 visit management_root_path
expect(page).to_not have_content('Language') expect(page).to_not have_content('Language')
expect(page).to_not have_css('div.locale') expect(page).to_not have_css('div.locale')
end end
end end

View File

@@ -46,7 +46,7 @@ describe CensusApi do
it "returns the response for the first valid variant" 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, "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, "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") response = api.call(1, "123456")
@@ -55,9 +55,9 @@ describe CensusApi do
end end
it "returns the last failed response" do it "returns the last failed response" do
expect(api).to receive(:get_response_body).with(1, "00123456").and_return(invalid_body) allow(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) 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(invalid_body) allow(api).to receive(:get_response_body).with(1, "0123456").and_return(invalid_body)
response = api.call(1, "123456") response = api.call(1, "123456")
expect(response).to_not be_valid expect(response).to_not be_valid

View File

@@ -34,7 +34,7 @@ describe LocalCensus do
it "returns the response for the first valid variant" 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, "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, "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") response = api.call(1, "123456")
@@ -43,9 +43,9 @@ describe LocalCensus do
end end
it "returns the last failed response" do it "returns the last failed response" do
expect(api).to receive(:get_record).with(1, "00123456").and_return(invalid_body) allow(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) allow(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, "0123456").and_return(invalid_body)
response = api.call(1, "123456") response = api.call(1, "123456")
expect(response).to_not be_valid expect(response).to_not be_valid

View File

@@ -47,13 +47,13 @@ describe ManagerAuthenticator do
it 'calls the verification user method' do it 'calls the verification user method' do
message = { ub: {user_key: "31415926", date: "20151031135905"} } message = { ub: {user_key: "31415926", date: "20151031135905"} }
allow(authenticator).to receive(:application_authorized?).and_return(true) 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 authenticator.auth
end end
it 'calls the permissions check method' do it 'calls the permissions check method' do
allow(authenticator).to receive(:manager_exists?).and_return(true) 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 authenticator.auth
end end
end end

View File

@@ -23,7 +23,7 @@ describe Notification do
describe "#for_render (scope)" do describe "#for_render (scope)" do
it "returns notifications including notifiable and user" 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 described_class.for_render
end end
end end

View File

@@ -185,7 +185,7 @@ describe Signature do
it "calls assign_vote_to_user" do it "calls assign_vote_to_user" do
signature = create(:signature, document_number: "12345678Z") signature = create(:signature, document_number: "12345678Z")
expect(signature).to receive(:assign_vote_to_user) allow(signature).to receive(:assign_vote_to_user)
signature.verify signature.verify
end end
@@ -219,4 +219,4 @@ describe Signature do
end end
end end

View File

@@ -39,9 +39,9 @@ describe Verification::Management::Email do
mail = double(:mail) mail = double(:mail)
allow(validation).to receive(:user).and_return user allow(validation).to receive(:user).and_return user
expect(mail).to receive(:deliver_later) allow(mail).to receive(:deliver_later)
expect(Devise.token_generator).to receive(:generate).with(User, :email_verification_token).and_return(["1", "2"]) allow(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(Mailer).to receive(:email_verification).with(user, user.email, "2", "1", "1234").and_return(mail)
validation.save validation.save