From 3ca865f4351e5f04d17e885cc8a8a6f977027540 Mon Sep 17 00:00:00 2001 From: James Mead Date: Sun, 8 Dec 2024 18:22:11 +0000 Subject: [PATCH] Document argument precedence for Expectation#with This is accidental and possibly undesirable behaviour, but it seems like an improvement to at least document the current behaviour. Clarifies potentially confusing behaviour which resulted in the opening of #606. --- lib/mocha/expectation.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/mocha/expectation.rb b/lib/mocha/expectation.rb index ebae85e7..8c27f059 100644 --- a/lib/mocha/expectation.rb +++ b/lib/mocha/expectation.rb @@ -194,6 +194,7 @@ def at_most_once # May be used with Ruby literals or variables for exact matching or with parameter matchers for less-specific matching, e.g. {ParameterMatchers#includes}, {ParameterMatchers#has_key}, etc. See {ParameterMatchers} for a list of all available parameter matchers. # # Alternatively a block argument can be passed to {#with} to implement custom parameter matching. The block receives the +*actual_parameters+ as its arguments and should return +true+ if they are acceptable or +false+ otherwise. See the example below where a method is expected to be called with a value divisible by 4. + # The block argument takes precedence over +expected_parameters_or_matchers+. # # Note that if {#with} is called multiple times on the same expectation, the last call takes precedence; other calls are ignored. #