Skip to content

Commit

Permalink
Add Ruby 3.4 support (#276)
Browse files Browse the repository at this point in the history
* Add csv to dependencies

* Add Ruby 3.4's Hash#inspect symbol change, rename file to fix typo

* Add Ruby 3.4 to  CI matrix
  • Loading branch information
cllns authored Jan 1, 2025
1 parent 63863fb commit 50826c9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
fail-fast: false
matrix:
ruby:
- "3.4"
- "3.3"
- "3.2"
- "3.1"
Expand Down
1 change: 1 addition & 0 deletions hanami-router.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "rack", "~> 2.0"
spec.add_dependency "mustermann", "~> 3.0"
spec.add_dependency "mustermann-contrib", "~> 3.0"
spec.add_dependency "csv", "~> 3.3"

spec.add_development_dependency "bundler", ">= 1.6", "< 3"
spec.add_development_dependency "rake", "~> 13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
response = @app.patch("/books/23", "CONTENT_TYPE" => "application/json", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))
else
expect(response.body).to eq(%({published: "true", id: "23"}))
end
end

# See https://github.com/hanami/router/issues/124
Expand All @@ -45,15 +50,25 @@
response = @app.patch("/books/23", "CONTENT_TYPE" => "application/json", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:id=>"23"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:id=>"23"}))
else
expect(response.body).to eq(%({id: "23"}))
end
end

it "is successful (JSON as array)" do
body = StringIO.new(%(["alpha", "beta"]).encode(Encoding::ASCII_8BIT))
response = @app.patch("/books/23", "CONTENT_TYPE" => "application/json", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:_=>["alpha", "beta"], :id=>"23"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:_=>["alpha", "beta"], :id=>"23"}))
else
expect(response.body).to eq(%({_: ["alpha", "beta"], id: "23"}))
end
end

# See https://github.com/hanami/utils/issues/169
Expand All @@ -62,7 +77,12 @@
response = @app.patch("/books/23", "CONTENT_TYPE" => "application/json", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:json_class=>"Foo", :id=>"23"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:json_class=>"Foo", :id=>"23"}))
else
expect(response.body).to eq(%({json_class: "Foo", id: "23"}))
end
end

it "is idempotent" do
Expand All @@ -71,7 +91,12 @@
response = @app.patch("/books/23", "CONTENT_TYPE" => "application/json", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))
else
expect(response.body).to eq(%({published: "true", id: "23"}))
end
end
end
end
Expand All @@ -82,15 +107,25 @@
response = @app.patch("/authors/23", "CONTENT_TYPE" => "application/xml", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:name=>"LG", :id=>"23"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:name=>"LG", :id=>"23"}))
else
expect(response.body).to eq(%({name: "LG", id: "23"}))
end
end

it "is successful (XML aliased mime)" do
body = StringIO.new(%(<name>MGF</name>).encode(Encoding::ASCII_8BIT))
response = @app.patch("/authors/15", "CONTENT_TYPE" => "text/xml", "rack.input" => body, lint: true)

expect(response.status).to eq(200)
expect(response.body).to eq(%({:name=>"MGF", :id=>"15"}))

if RUBY_VERSION < "3.4"
expect(response.body).to eq(%({:name=>"MGF", :id=>"15"}))
else
expect(response.body).to eq(%({name: "MGF", id: "15"}))
end
end
end
end

0 comments on commit 50826c9

Please sign in to comment.