[rspec-users] How to mock when there seems to be a requirement for chained mocked calls?
dchelimsky at gmail.com
Mon Jun 13 21:37:59 EDT 2011
On Jun 13, 2011, at 8:29 PM, S Ahmed wrote:
"How to mock when there seems to be a requirement for chained mocked calls?"
There is no such requirement unless you are imposing it by your own design decisions.
> I want to mock the following:
Why do you want to do this? Is this in a model spec? A controller spec?
> I tried:
> but this of course doesn't match the expectation since the call to .last was not mapped in the mock code.
> How can I do this?
You _can_ stub (not mock) chains like this:
You can also set chained expectations like this (but I wouldn't recommend it):
ar_query = double('ar_query')
More information about the rspec-users