[mocha-developer] Parameter Matchers with optional params

James Mead jamesmead44 at gmail.com
Mon Sep 24 06:11:49 EDT 2007


On 24/09/2007, Andrew Vit <andrew at avit.ca> wrote:
>
> Are there any docs for combining parameter matchers, or some way to
> define optional parameters? I'm trying to match something like:
>
>    .find( 42 )  ||  .find( 42, {:conditions=>nil,:includes=>nil} )
>
> Or for that matter, 42 followed by nothing or anything... Halp? I've
> tried different nested combos with any_of/all_of/anything, but
> getting lost trying.
>

Hi Andrew,

For the moment, I think you should be able to use the "parameter_block"
version of Expectation#with (
http://mocha.rubyforge.org/classes/Mocha/Expectation.html#M000024).

However, just to warn you, I'm intending to deprecate this mechanism in the
near future, but not until I can provide an alternative mechanism using
something similar to the ParameterMatcher style. I'll try to post here when
I get something committed.

Please let me know if you think the documentation could be improved.

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


More information about the mocha-developer mailing list