-
-
Notifications
You must be signed in to change notification settings - Fork 354
Add tests and fix for ruby 3 keyword arguments issues #1407
Add tests and fix for ruby 3 keyword arguments issues #1407
Conversation
Thanks for tackling this, you need to wrap the specs in eval blocks so that they can safely be ignored by legacy Rubies. Theres examples around of this in #1385 |
Thanks for the review and the pointer. I was unsure how rspec handled keyword args and legacy rubies. Do you want me to add more specs for keyword args in the other spots that I highlighted? Our codebase didn't run into issues with those spots but I'm happy to attempt a reproduction or add more keyword argument tests in general. |
More keyword specs in examples are welcome, we are lacking that aspect of coverage, although I'd prefer a seperate PR for general keyword examples, and focus this on your fix 👍 |
f4ded4a
to
585bc7e
Compare
This looks great apart from the JRuby failures, can you investigate? |
71cefb8
to
1bf14e8
Compare
Was this fix really for JRuby? If we are differing on some language-level behavior compared to an equivalent CRuby, we definitely would like to see a bug report for that. Edit: referring to 740046b |
@JonRowe It was a bad test setup. I set it to false for the test that pass block implementations. I could move the test into the individual blocks (allow(...).to receive/expect(...).to receive/allow_any_instance_of.to receive/expect_any_instance_of.to receive |
@headius, I can write something up. Let me create a simpler repro. |
1bf14e8
to
e6e0ef0
Compare
…-any-instance Add tests and fix for ruby 3 keyword arguments issues
Thanks 🙏 |
@JonRowe can we push a release for this? Currently upgrading to Ruby 3 breaks a whole lot of specs. |
A release is planned but I have to fix some CI issues first. |
Released as v3.10.2 |
Awesome, thanks! |
…ess/add-kwarg-support-for-any-instance Add tests and fix for ruby 3 keyword arguments issues --- This commit was imported from rspec/rspec-mocks@4e607c0.
[skip ci] --- This commit was imported from rspec/rspec-mocks@ade4efa.
…ess/add-kwarg-support-for-any-instance Add tests and fix for ruby 3 keyword arguments issues --- This commit was imported from rspec/rspec-mocks@d0b96af.
[skip ci] --- This commit was imported from rspec/rspec-mocks@675f32e.
I recently ran into a similar issue to #1396 when upgrading our codebase to ruby 3.
This PR adds tests for both scenarios (
receive
with a block with kwargs andand_call_original
when mocking a method that uses keyword arguments). The tests may be redundant since fixing recorder fixed both tests.I noticed other spots where define_method is used to intercept method calls (e.g.
rspec-mocks/lib/rspec/mocks/any_instance/chain.rb
Line 27 in 0a52e0a
rspec-mocks/lib/rspec/mocks/matchers/receive.rb
Line 61 in 0a52e0a