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

Run CI against Ruby 3.2 #742

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
ruby: [ ruby-2.6, ruby-2.7, ruby-3.0, ruby-3.1 ]
ruby: [ ruby-2.6, ruby-2.7, ruby-3.0, ruby-3.1, ruby-3.2 ]
os: [ ubuntu-latest ]

steps:
Expand Down
6 changes: 5 additions & 1 deletion spec/lib/http/options/headers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
end

it "accepts any object that respond to :to_hash" do
x = Struct.new(:to_hash).new("accept" => "json")
x = if RUBY_VERSION >= "3.2.0"
Data.define(:to_hash).new(:to_hash => { "accept" => "json" })
else
Struct.new(:to_hash).new({ "accept" => "json" })
end
Comment on lines +17 to +21
Copy link
Contributor Author

@koheisg koheisg Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x = if RUBY_VERSION >= "3.2.0"
Data.define(:to_hash).new(:to_hash => { "accept" => "json" })
else
Struct.new(:to_hash).new({ "accept" => "json" })
end
Struct.new(:to_hash, keyword_init: false).new("accept" => "json")

If this is the case, the code will not branch by version, but keyword_init: false will cause rubocop to say `Use hash rockets syntax.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should migrate from hashrockets to keyword args in general, and that's long overdue.

I would suggest disabling the rubocop lint for hashrockets.

expect(opts.with_headers(x).headers["accept"]).to eq("json")
end
end