Closed floehopper closed 6 months ago
@CodingAnarchy Are you able to confirm that this fixes the problem in #647?
@floehopper I tested with this branch in our tests, and it works great! Thanks for the quick response!
@floehopper I tested with this branch in our tests, and it works great! Thanks for the quick response!
Great - thanks for letting me know - I'll try to get this merged and released as soon as I can.
EDIT: created a proper issue https://github.com/freerange/mocha/issues/654
This is a breaking change, isn't it? If so, did we mean it to be?
The test below fails with mocha 2.2.0
but succeeds in 2.4.0
.
require "bundler/setup"
require "minitest/autorun"
require "mocha/minitest"
require "mocha/mock"
class FooTest < Minitest::Test
def setup
@mock = mock("foo")
end
def test_mocha_mocking_kw_args_with_has_entry
@mock.expects(:bar).with(has_entry(:a, k: "v"))
@mock.bar(a: { k: "v", extra: "extra" })
end
end
One can argue the new behaviour is even buggy, because if I want the above test to pass I should configure my expectation as @mock.expects(:bar).with(has_entry(:a, has_entry(k: "v")))
.
Previously, parameter matching for keyword arguments only worked when the matchers specified the exact value of each argument. This change means that we make use of the
HasEntries
matcher to ensure that any matchers for each of the keyword arguments are also taken into account.Fixes #647.