Skip to content

Commit

Permalink
Document Expectation#with called multiple times
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.
  • Loading branch information
floehopper committed Dec 8, 2024
1 parent c3b4b8e commit 99f3f6b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mocha/expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ 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.
#
# Note that if {#with} is called multiple times on the same expectation, the last call takes precedence; other calls are ignored.
#
# Positional arguments were separated from keyword arguments in Ruby v3 (see {https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0 this article}). In relation to this a new configuration option ({Configuration#strict_keyword_argument_matching=}) is available in Ruby >= 2.7.
#
# When {Configuration#strict_keyword_argument_matching=} is set to +false+ (which is currently the default), a positional +Hash+ and a set of keyword arguments passed to {#with} are treated the same for the purposes of parameter matching. However, a deprecation warning will be displayed if a positional +Hash+ matches a set of keyword arguments or vice versa. This is because {Configuration#strict_keyword_argument_matching=} will default to +true+ in the future.
Expand Down

0 comments on commit 99f3f6b

Please sign in to comment.