with(...) { ... }
should match both given args and block, or reject both
#606
Labels
with(...) { ... }
should match both given args and block, or reject both
#606
Context
Consider the following code
Currently, only the block matcher will be checked, and
instance_of(Foo)
will be ignored.This is because specifying
expected_parameters
and amatching_block
are silently mutually exclusive. We can see this by following the code toParametersMatcher#match?
mocha/lib/mocha/expectation.rb
Lines 269 to 272 in f7e1763
mocha/lib/mocha/parameters_matcher.rb
Lines 5 to 18 in f7e1763
match?
checks if a block was provided, and if so matches against that. It only matches against theexpected_parameters
if no block was given.This means it is possible to write the following passing test:
Proposal
Match against the parameter matchers and the block. Something like:
Raise if passed both expected parameters and a block are given
Opinion
My gut feeling is🅰️ would be better.
The text was updated successfully, but these errors were encountered: