[mocha-developer] Expecting calls with two different parameters

James Mead jamesmead44 at gmail.com
Mon Oct 9 03:51:14 EDT 2006


On 08/10/06, Bryan Helmkamp <bhelmkamp at gmail.com> wrote:
>
> Thanks, Kevin and James.  The key is instead of writing the mock like
> this:
>
> foo.expects(:bar)
> foo.expects(:bar).with("something")
>
> You have to write it like this:
>
> foo.expects(:bar).with()
> foo.expects(:bar).with("something")
>
> The first example won't work.  If you don't want to specify the
> paramaters passed in one of the method calls, you can do:
>
> foo.expects(:bar).times(2)
> foo.expects(:bar).with("something")
>
> And that works too.
>
> Thanks,
>
> -Bryan
>

I'm glad you've worked it out - I'm still not clear what the issue was. It
would be clearer if you showed the actual method calls as well as the
expectations.

I'm keen to observe the principle of least surprise, so please let me know
if an aspect of the Mocha API didn't work how you expected.

-- 
James.
http://blog.floehopper.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061009/5cb67b1d/attachment.html 


More information about the mocha-developer mailing list