Skip to content

Commit

Permalink
Document argument precedence for Expectation#with
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
floehopper committed Dec 8, 2024
1 parent 558d521 commit 3ca865f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/mocha/expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down

0 comments on commit 3ca865f

Please sign in to comment.