Closed JeanSebTr closed 2 years ago
Thank you! I'll add Ruby 3 to the GH actions to make sure this fixes what you're describing.
@JeanSebTr - I looked into your PR today.
It seems ruby2_keywords
was added to Ruby in 2.7. What if somebody (hopefully not 🤞 ) is using LS with Ruby <2.7? Could we add a guard clause for your statement?
Also, I'd love to see a unit test added for this change. Can you help me with that?
Thank you so much!
It seems
ruby2_keywords
was added to Ruby in 2.7. What if somebody (hopefully not 🤞 ) is using LS with Ruby <2.7? Could we add a guard clause for your statement?
There is one: ruby2_keywords :with if RUBY_VERSION >= "2.7"
as most ruby stuff, ruby2_keywords
is a normal method and not a special keyword. I'm open to suggestions if it should take a different form than an if modifier.
I'll look into adding a test for it!
Your change might fix this.
looks like fixing that cop would require using (...)
which would require dropping support for ruby < 2.7
Hi @adomokos !
I've rebased on main and added a spec covering this. I didn't manage to run them locally tho
Okay, managed to run specs locally, fixed the spec and made sure it fail on 3.0 without the fix.
Tried to suggest how to fix the CI in https://github.com/JeanSebTr/light-service/pull/2
On my repo it turned the CI green again.
Regarding the conversion about the backward compatibility, I'd like to leave this link https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ as a reference into the PR.
Ok, sorry about all that back and forth. I've applied @adomokos suggestions and ran both rspec and rubocop locally. Re-tested as well without the fix and the spec does fail.
I already participated in the PR, deepened the matter, had the same need on a project and poor-man-tested the solution using 2.6 and 3.1: FWIW LGTM 🙂
Do you guys need this released as a new version of the gem?
@adomokos On our side, we're not in a hurry to migrate to ruby 3, so I don't mind if you prefer waiting for other stuff to release a version.
I've tried to update one of our project to ruby 3.0 and the only issue was in our services spec using ContextFactory.
We use named argument a lot and 3.0 break this when they're not passed explicitly using the double splat operator.
ruby2_keywords
marks the method as using the old style of named arguments. Calling it this way should works with older 2.x versions as well.