From 17a4856454740579439737fa621379b9e2349850 Mon Sep 17 00:00:00 2001 From: James Mead Date: Sun, 8 Dec 2024 18:26:04 +0000 Subject: [PATCH] Improve docs for Expectation#with when passed block Addressed an aside in the description of #682. This originally came up in this commit [1]. [1]: https://github.com/freerange/mocha/commit/73c4ea6ef5def4f9203e7a0d6f3a460849d511bb --- lib/mocha/expectation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mocha/expectation.rb b/lib/mocha/expectation.rb index 8c27f059..87a6eeb7 100644 --- a/lib/mocha/expectation.rb +++ b/lib/mocha/expectation.rb @@ -194,7 +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+. + # The block argument takes precedence over +expected_parameters_or_matchers+. The block may be called multiple times per invocation of the expected method and so it should be idempotent. # # Note that if {#with} is called multiple times on the same expectation, the last call takes precedence; other calls are ignored. #