I need to set expectation on one single argument. How can I access the received arguments from RSpec?
Here is what I want to achieve.
let(:api) { double('API') }
it "should pass :filter in options" do
api.should_receive(:traverse)
subject.execute
args = api.recevied_arguments_for(:traverse) # How to obtain all the arguments?
args[0].should have_key(:filter)
end
To answer the question, fix the line with the comment.
Thanks.
Just figured it out. Much better than I thought.
let(:api) { double('API') }
it "should pass :filter in options" do
api.should_receive(:traverse).with hash_including(:filter)
# or with the exact value
#api.should_receive(:traverse).with hash_including(:filter => 'something')
subject.execute
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