Skip to content
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

Update grep_keys to work in Ruby 3+ #492

Merged
merged 2 commits into from
Apr 30, 2023

Conversation

helenasw
Copy link
Contributor

Pass argument opts as keyword arguments to select_keys. Fixes issue #491

@helenasw
Copy link
Contributor Author

Testing

My test fails with Ruby 3.0 on main

$ git co main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
$ ruby -v
ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [x86_64-darwin20]
$ bundle exec rspec spec/locale_tree/traversal_spec.rb
F

Failures:

  1) I18n::Tasks::Data::Tree::Traversal#grep_keys returns Siblings
     Failure/Error:
       def select_keys(root: false, &block)
         matches = get_nodes_by_key_filter(root: root, &block)
         select_nodes do |node|
           matches.include?(node)
         end
       end

     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     # ./lib/i18n/tasks/data/tree/traversal.rb:123:in `select_keys'
     # ./lib/i18n/tasks/data/tree/traversal.rb:164:in `grep_keys'
     # ./spec/locale_tree/traversal_spec.rb:9:in `block (3 levels) in <top (required)>'

Finished in 0.02289 seconds (files took 1.25 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/locale_tree/traversal_spec.rb:8 # I18n::Tasks::Data::Tree::Traversal#grep_keys returns Siblings

Test passes with Ruby 3.0 on my branch

$ git co update-grep_keys-for-ruby-3
Already on 'update-grep_keys-for-ruby-3'
Your branch is up to date with 'origin/update-grep_keys-for-ruby-3'.
$ ruby -v
ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [x86_64-darwin20]
$ bundle exec rspec spec/locale_tree/traversal_spec.rb
.

Finished in 0.02681 seconds (files took 0.71112 seconds to load)
1 example, 0 failures

Test passes with Ruby 2.7 on my branch

$ git co update-grep_keys-for-ruby-3
Already on 'update-grep_keys-for-ruby-3'
Your branch is up to date with 'origin/update-grep_keys-for-ruby-3'.
$ ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin20]
$ bundle exec rspec spec/locale_tree/traversal_spec.rb
warning: parser/current is loading parser/ruby27, which recognizes 2.7.7-compliant syntax, but you are running 2.7.6.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
.

Finished in 0.02415 seconds (files took 0.70896 seconds to load)
1 example, 0 failures

@helenasw helenasw marked this pull request as ready for review February 24, 2023 16:01
@glebm
Copy link
Owner

glebm commented Feb 24, 2023

Thanks!

@davidwessman
Copy link
Collaborator

@glebm Do we need to fix anything more in this PR?

@glebm glebm merged commit eb51568 into glebm:main Apr 30, 2023
@glebm
Copy link
Owner

glebm commented Apr 30, 2023

This slipped through the cracks, sorry! Merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants