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

Add Ruby 3.4 support #276

Merged
merged 3 commits into from
Jan 1, 2025
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
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
Loading