Conversation
|
|
||
| it 'works for the method propagated by method missing' do | ||
| expect(instance).to receive(:existing_method).with(:arg, kwarg: 1).and_call_original | ||
| expect(instance.existing_method(:arg, kwarg: 1)).to eq([:arg, 1]) |
There was a problem hiding this comment.
This test actually reproduces the error in Ruby 3.2
Failure/Error:
def existing_method_with_args(arg, kwarg:)
[arg, kwarg]
end
ArgumentError:
wrong number of arguments (given 2, expected 1; required keyword: kwarg)623ee32 to
fa671b0
Compare
| def existing_method_with_args(arg, kwarg:) | ||
| [arg, kwarg] | ||
| end | ||
|
|
||
| def method_missing(name, *args, **kwargs) |
There was a problem hiding this comment.
You'll need to eval these from strings conditionally to pass our build
There was a problem hiding this comment.
@JonRowe thanks, done! Let's see if it helps 👍
fa671b0 to
e262bf4
Compare
| if name.to_s == "greet_jack" | ||
| "Hello, jack" | ||
| elsif name.to_s == "method_with_kwarg" | ||
| call_method_with_kwarg(*args, **kwargs) |
There was a problem hiding this comment.
This will also need to be wrapped to pass our build, until we release RSpec 4 we support pre keyword rubies (sorry)
There was a problem hiding this comment.
@JonRowe ah, got it, I've changed the code, and now all the new examples are evaluated conditionally 👍
There was a problem hiding this comment.
Ruby 2.0 failed because the kwarg doesn't have a default value, I changed the condition to run only when required-kwarg are available. Hope it will pass now
828ba9d to
f43911b
Compare
When the original method isn't present, a proc that sends method_missing is returned. This block must support ruby2_keywords in order to work correctly with Ruby 3.2
f43911b to
c926345
Compare
|
Thanks! |
…-method-double Fix and_call_original for Ruby 3.2
|
Released in 3.12.6 |
When the original method isn't present, a proc that sends method_missing is returned. This block must support ruby2_keywords in order to work correctly with Ruby 3.2.
Otherwise, the following error is raised