-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Delegate kwargs when defining a method with chain
#1374
base: main
Are you sure you want to change the base?
Conversation
As you may see, May I kindly ask you to separate the fix for this case from - @divisor % to_match == 0
+ to_match % @divisor == 0 fixes? And potentially add an example that would indicate that the previous implementation was incorrect. |
11297ea
to
84a6e67
Compare
Good catch — thanks for the link! Pushed up a fixed commit. Minor clarification:
I would be happy to, except that breaks my test.
As you can see, 10 is divisible by 1. I would rather just leave off the
since it's the test would be simpler without it, but when I tried that, it raised: TypeError:
nil can't be coerced into Integer
# ./spec/rspec/matchers/dsl_spec.rb:381:in `%' I considered doing further refactoring to make the Rather than wasting more time strategizing how best to incorporate this trivial test bug fix, may we please just include it here? Or, if you'd prefer, would you mind just fixing the tests to however you'd like them? (I enabled the "Allow edits" option.) |
Let's go for it 👍 |
I suggest extracting those specs with the matcher involving block kwargs into a separate one, as we still support Ruby < 2. |
Without this, it will raise: ArgumentError: wrong number of arguments (given 2, expected 1) if you try to pass a keyword arg to a chain method on Ruby 3. In Ruby 3, you _must_ explicitly delegate keyword arguments. (See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#delegation-ruby-3 and https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html)
84a6e67
to
29b4f6e
Compare
chain
chain
8d8414b
to
5a7e7cc
Compare
5a7e7cc
to
205da51
Compare
Without this, it will raise:
if you try to pass a keyword arg to a chain method on Ruby 3.
In Ruby, you must explicitly delegate keyword arguments. (See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#delegation-ruby-3)