Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rspec expect to receive caring about just one parameter a couple times

I wanted to do the following within rspec: Test that a method get's called with a particular argument no matter what the others are.

For example I would like to test MyClass.receive(:new).with(anything, anything, testedObject). Is this possible to do with rspec?

like image 840
Pablo Avatar asked Oct 31 '25 03:10

Pablo


1 Answers

Yes, see doc:

MyClass.should_receive(:new).with(anything, anything, your_object)
like image 104
apneadiving Avatar answered Nov 02 '25 18:11

apneadiving



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!