I have some Ruby code which looks like this:
Something.create do |x|
x.foo = bar
end
I'd like to write a test which uses a double in place of the block argument x, so that I can then call:
x_double.should_receive(:foo).with("whatever").
Is this possible?
specify 'something' do
x = double
x.should_receive(:foo=).with("whatever")
Something.should_receive(:create).and_yield(x)
# call the relevant method
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With