Fix a NoMethodError on Ruby 2.7 caused by Hash#except#468
Open
koic wants to merge 1 commit into
Open
Conversation
## Motivation and Context
The gemspec already declares `required_ruby_version >= 2.7.0`, but the conformance Rake task used `Hash#except` to drop
the `:port` option before handing the remaining options to `Conformance::ClientRunner`. `Hash#except` was only added in Ruby 3.0,
so running `rake conformance` on Ruby 2.7 aborted before any scenario ran, raising `NoMethodError: undefined method except for {}:Hash`.
CI missed this because no job runs `rake conformance` on Ruby 2.7: the conformance workflow runs only on Ruby 4.0,
while the Ruby 2.7.0 matrix entry runs `rake test` alone.
## How Has This Been Tested?
Replace `options.except(:port)` with `options.reject { |key, _| key == :port }`, which has been available since well
before Ruby 2.7 and returns an equivalent Hash without mutating the original. `rake conformance` now runs the full suite on Ruby 2.7,
and its baseline still passes on current Ruby, verified on Ruby 4.0.
## Breaking Changes
None.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The gemspec already declares
required_ruby_version >= 2.7.0, but the conformance Rake task usedHash#exceptto drop the:portoption before handing the remaining options toConformance::ClientRunner.Hash#exceptwas only added in Ruby 3.0, so runningrake conformanceon Ruby 2.7 aborted before any scenario ran, raisingNoMethodError: undefined method except for {}:Hash.CI missed this because no job runs
rake conformanceon Ruby 2.7: the conformance workflow runs only on Ruby 4.0, while the Ruby 2.7.0 matrix entry runsrake testalone.How Has This Been Tested?
Replace
options.except(:port)withoptions.reject { |key, _| key == :port }, which has been available since well before Ruby 2.7 and returns an equivalent Hash without mutating the original.rake conformancenow runs the full suite on Ruby 2.7, and its baseline still passes on current Ruby, verified on Ruby 4.0.Breaking Changes
None.
Types of changes
Checklist