-
Notifications
You must be signed in to change notification settings - Fork 556
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
If a callable mock includes kwargs, Ruby 2.7 warns #824
Conversation
This patch wrecks havoc on the tests if ruby < 2.7:
|
and presumably you'd want |
Ahh sorry I didn't realize that would break things from earlier Ruby versions. I've added a switch on I'm not sure what you mean about |
@zenspider anything I can do to help get this in? |
The implementation is wrong, it should use |
@jeremyevans we're modifying the way in which we call the callable proc here, not the method that surrounds it. I don't think That being said if you can find a way to make it work with |
The arguments passed to the proc come from |
Wow dude. Yes I have tried multiple times to get this to work with |
Apologies. I'm not trying to attack you, I just did not see anywhere earlier in this where it states that |
This appears to work with your test: diff --git a/lib/minitest/mock.rb b/lib/minitest/mock.rb
index 39cfc24..6fc97e3 100644
--- a/lib/minitest/mock.rb
+++ b/lib/minitest/mock.rb
@@ -230,6 +230,7 @@ class Object
val_or_callable
end
end
+ metaclass.send(:ruby2_keywords, name) if metaclass.respond_to?(:ruby2_keywords, true)
yield self
ensure |
This commit handles kwargs using ruby2_keywords, and adds a test to assert that the warning is gone.
@jeremyevans thank you for the help. I've updated the pull request per your suggestion. |
Thanks everyone. I’m currently celebrating an anniversary but I’ll try to get on this shortly. I have a pressing hoe release that’ll be a forcing function on this as well. |
May be related: Nakilon@3fc22e7#diff-2a72d0121a0eb22e9f32a1ce654e5132391273007bf643b5ae68fbbc2800dea4 |
I agree, this is what we need to get merged here and released in a new gem version. I imagine this is currently a problem for anyone stubbing methods with kwargs. |
GAH... I totally forgot about this PR and basically did the same thing myself yesterday... I had clicked through on the email from @Nakilon's comment and ignored the wider context. Sorry! I'll add you to the changelog. |
This commit explicitly forwards kwargs to remove the warning, and adds a test to assert that it was silent.