Closed marcotc closed 1 year ago
Thanks for reporting. Would you like to take a stab at a pr with at least a failing spec?
What the change that resulted in the regression was supposed to fix?
Can’t tell upfront, but it may require a change on RSpec-support side. I believe there is an open ticket with some discussion regarding argument matching, do you mind checking if they are somewhat similar?
This is fixed in 3.12.0
, thank you so much!
Subject of the issue
When upgrading to 3.10.3 today, I noticed one test failure in our CI matrix that only affected Ruby 2.7.
This issue happens when we provide an empty keyword argument Hash as a keyword splat argument (
method(**{})
) toRSpec::Mocks::Matchers::Receive#with
. Example:expect(obj).to receive(:call).with(:foo, **{})
.When later invoking
obj.call(:foo, **{})
I receive theexpected: (:foo, {}) got: (:foo)
assertion error.This does not affect Ruby < 2.7, nor Ruby > 2.7. Nor it affects rspec-mocks 3.10.2.
Preliminary investigation
Looking at the changelog for v3.10.3, I can see changes around
ruby2_keywords
, and it looks like the empty keyword argument{}
get dropped in this invocation: https://github.com/rspec/rspec-mocks/blob/97c972be57f2c060a4a7fb8a3c5700a5ede693f0/lib/rspec/mocks/method_double.rb#L64Another option is to filter out the empty hash before is gets stored in the
args
here: https://github.com/rspec/rspec-mocks/blob/97c972be57f2c060a4a7fb8a3c5700a5ede693f0/lib/rspec/mocks/matchers/receive_message_chain.rb#L18I'm not sure which of these avenues is the correct one, though.
Your environment
Steps to reproduce
Expected behavior
Assertion to match, and test to pass:
Actual behavior