rspec undefined method `receive' for expect syntax
By : siva
Date : March 29 2020, 07:55 AM
|
RSpec expect to receive method with array but order does not matter
By : MusicLife
Date : March 29 2020, 07:55 AM
it fixes the issue You can pass any RSpec matcher to with, and contain_exactly(1, 2, 3) does exactly what you want, so you can pass that to with: code :
expect(calculation_service).to receive(:sum?).with(contain_exactly(1, 2, 3)) { 6 }
expect(calculation_service).to receive(:sum?).with(
a_collection_containing_exactly(1, 2, 3)
) { 6 }
|
Rspec expect method to receive ActiveRecord::Relation
By : Waseem Sangrar
Date : March 29 2020, 07:55 AM
seems to work fine Instead of faking bars, you could check that bars is the value you expect: code :
expect(described_class).to receive(:foo) do |bars|
# verify bars here. You could do bars.to_a and check the array
# or bars.to_sql and check the generated sql.
end
|
rspec expect child to receive method when parent method is called
By : testingtester
Date : March 29 2020, 07:55 AM
I wish this help you After a lot more digging, the issue is that my comment variable isn't actually exactly the same instance as the variable that RSpec sees in the loop. They differ by the Rails object ID that is assigned on the fly. I needed to use a spy or stub the method to avoid this issue.
|
Rspec expect(instance) to receive method not working as expected
By : Mohammad Shannak
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Firstly you need to stub the lines in controller in order to expect some code
|