Reputation: 13012
I am converting a bunch of spec's from rspec 2 to 3 syntax.
there is this particular stub.
mail.stub(deliver: mail)
I have tried several things to get this to the new syntax but I am struggling a bit.
I have tried
allow(mail).to receive(deliver: mail)
Which will result in an
undefined method `to_sym' for {:deliver=>#<Double "mail">}:Hash
any help with this particular stub would be great.
Upvotes: 1
Views: 88
Reputation: 2614
If it's a stub you can add a return block, ignoring the passed arguments, like so:
allow(mail).to receive(:deliver) { 'hello' }
If its an expectation you can use the #with method to verify arguments:
expect(mail).to receive(:deliver).with(mail) { 'hello' }
https://relishapp.com/rspec/rspec-mocks/docs
Upvotes: 2