Fix RSpec/StubbedMock
cop (#25552)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
2e1391fdd2
commit
6c5a2233a8
9 changed files with 26 additions and 31 deletions
|
@ -23,7 +23,7 @@ describe StatusFilter do
|
|||
|
||||
context 'when status policy does not allow show' do
|
||||
it 'filters the status' do
|
||||
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
allow_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
|
||||
expect(filter).to be_filtered
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ describe StatusFilter do
|
|||
|
||||
context 'when status policy does not allow show' do
|
||||
it 'filters the status' do
|
||||
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
allow_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
|
||||
expect(filter).to be_filtered
|
||||
end
|
||||
|
|
|
@ -18,10 +18,13 @@ describe StatusFinder do
|
|||
|
||||
it 'raises an error if action is not :show' do
|
||||
recognized = Rails.application.routes.recognize_path(url)
|
||||
expect(recognized).to receive(:[]).with(:action).and_return(:create)
|
||||
expect(Rails.application.routes).to receive(:recognize_path).with(url).and_return(recognized)
|
||||
allow(recognized).to receive(:[]).with(:action).and_return(:create)
|
||||
allow(Rails.application.routes).to receive(:recognize_path).with(url).and_return(recognized)
|
||||
|
||||
expect { subject.status }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
|
||||
expect(Rails.application.routes).to have_received(:recognize_path)
|
||||
expect(recognized).to have_received(:[])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,13 +27,14 @@ describe WebfingerResource do
|
|||
recognized = Rails.application.routes.recognize_path(resource)
|
||||
allow(recognized).to receive(:[]).with(:controller).and_return('accounts')
|
||||
allow(recognized).to receive(:[]).with(:username).and_return('alice')
|
||||
expect(recognized).to receive(:[]).with(:action).and_return('create')
|
||||
allow(recognized).to receive(:[]).with(:action).and_return('create')
|
||||
|
||||
expect(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized).at_least(:once)
|
||||
|
||||
expect do
|
||||
described_class.new(resource).username
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(recognized).to have_received(:[]).exactly(3).times
|
||||
end
|
||||
|
||||
it 'raises with a string that doesnt start with URL' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue