Is it possible to check if the parameters passed to the parameters of a method call fulfill certain constraints. I would like to do something like
my_double = double("MyObject")
my_double.should_receive(:mocked_method).with{ <something that has an attribute called name and value "john"> }
Thanks a lot in advance.
Edit: I'll try to clarify a bit what I want to accomplish
What I want is to check that a given method of a mock was called passing an object that fulfils some conditions
For the record. What I wanted to accomplish can be made with
@test_double.should_receive(:send_mail) do |mail|
mail.to.should eq(["[email protected]"])
mail.body.decoded.should include "Error"
end
And the code should call the method send_mail of the given object with a parameter that fulfills the conditions specified in the block.
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