Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Copy Markdown
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
Copy Markdown
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