Fix RSpec/MessageSpies
cop (#27751)
This commit is contained in:
parent
ae0d551d33
commit
49e2772064
19 changed files with 162 additions and 94 deletions
|
@ -120,8 +120,11 @@ RSpec.describe Remotable do
|
|||
end
|
||||
|
||||
it 'does not try to write attribute' do
|
||||
expect(foo).to_not receive('[]=').with(attribute_name, url)
|
||||
allow(foo).to receive('[]=').with(attribute_name, url)
|
||||
|
||||
foo.hoge_remote_url = url
|
||||
|
||||
expect(foo).to_not have_received('[]=').with(attribute_name, url)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -131,8 +134,11 @@ RSpec.describe Remotable do
|
|||
end
|
||||
|
||||
it 'does not try to write attribute' do
|
||||
expect(foo).to receive('[]=').with(attribute_name, url)
|
||||
allow(foo).to receive('[]=').with(attribute_name, url)
|
||||
|
||||
foo.hoge_remote_url = url
|
||||
|
||||
expect(foo).to have_received('[]=').with(attribute_name, url)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -146,10 +152,13 @@ RSpec.describe Remotable do
|
|||
let(:code) { 500 }
|
||||
|
||||
it 'does not assign file' do
|
||||
expect(foo).to_not receive(:public_send).with("#{hoge}=", any_args)
|
||||
expect(foo).to_not receive(:public_send).with("#{hoge}_file_name=", any_args)
|
||||
allow(foo).to receive(:public_send)
|
||||
allow(foo).to receive(:public_send)
|
||||
|
||||
foo.hoge_remote_url = url
|
||||
|
||||
expect(foo).to_not have_received(:public_send).with("#{hoge}=", any_args)
|
||||
expect(foo).to_not have_received(:public_send).with("#{hoge}_file_name=", any_args)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -165,13 +174,13 @@ RSpec.describe Remotable do
|
|||
|
||||
allow(ResponseWithLimit).to receive(:new).with(anything, anything).and_return(response_with_limit)
|
||||
|
||||
expect(foo).to receive(:public_send).with("download_#{hoge}!", url)
|
||||
|
||||
allow(foo).to receive(:public_send)
|
||||
foo.hoge_remote_url = url
|
||||
expect(foo).to have_received(:public_send).with("download_#{hoge}!", url)
|
||||
|
||||
expect(foo).to receive(:public_send).with("#{hoge}=", response_with_limit)
|
||||
|
||||
allow(foo).to receive(:public_send)
|
||||
foo.download_hoge!(url)
|
||||
expect(foo).to have_received(:public_send).with("#{hoge}=", response_with_limit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -193,10 +202,13 @@ RSpec.describe Remotable do
|
|||
let(:error_class) { error_class }
|
||||
|
||||
it 'calls Rails.logger.debug' do
|
||||
expect(Rails.logger).to receive(:debug) do |&block|
|
||||
allow(Rails.logger).to receive(:debug)
|
||||
|
||||
foo.hoge_remote_url = url
|
||||
|
||||
expect(Rails.logger).to have_received(:debug) do |&block|
|
||||
expect(block.call).to match(/^Error fetching remote #{hoge}: /)
|
||||
end
|
||||
foo.hoge_remote_url = url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue