-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyword argument expectation matching failing in Ruby 2.7 #1457
Comments
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 |
Eric-Guo
added a commit
to Eric-Guo/wechat
that referenced
this issue
Apr 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:rspec-mocks/lib/rspec/mocks/method_double.rb
Line 64 in 97c972b
Another option is to filter out the empty hash before is gets stored in the
args
here:rspec-mocks/lib/rspec/mocks/matchers/receive_message_chain.rb
Line 18 in 97c972b
I'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
The text was updated successfully, but these errors were encountered: