[mocha-developer] Insure a method is called with no arguments.

James Mead jamesmead44 at gmail.com
Thu Oct 25 17:21:08 EDT 2007


On 25/10/2007, Duncan Beevers <duncanbeevers at gmail.com> wrote:
>
> We've been working with the ParameterMatchers (so cool!) but I don't
> see a way to insure a method is called with no arguments.
>
> I imagined something like:
>
> user = mock('User')
> user.expects(:friends).with(nothing)
>
> Anyone run into this?
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>

I'm glad you're finding the ParameterMatchers useful. You should be able to
do what you want by using with() with no parameters.
mock.expects(:method).with()

Let me know if that doesn't work.

In any case I quite like the nothing matcher idea, so I might add it as a
more expressive alternative.

Thanks

-- 
James.
http://blog.floehopper.org
http://tumble.floehopper.org


More information about the mocha-developer mailing list