Reputation: 3770
Rspec question
having
puts x.y
x.y = nil
I want to test if this line has been executed
so something like
allow(x).to receive(:y) { 'abc' }
and then
expect(x).to have_received(:y).with nil
but with(nil) doesn't work
any suggestions?
I want to make sure y is set to nil, but I cannot just check the value since I am stubbing x.y beforehand
Upvotes: 0
Views: 97
Reputation: 9858
You are attempting to assert that
x.y(nil)
is called.
To assert that the method y=
is called with nil
parameter, you'd want to use the :y=
symbol instead.
allow(x).to receive(:y=){ "xyz" }
expect(x).to have_received(:y=).with(nil)
Upvotes: 3