Skip to content

Commit ab06e1a

Browse files
committed
Add Ruby 3.4's Hash#inspect symbol change, rename file to fix typo
1 parent ffda241 commit ab06e1a

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

spec/integration/hanami/router/body_parsing_middelware_spec.rb spec/integration/hanami/router/body_parsing_middleware_spec.rb

+42-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
response = @app.patch("/books/23", "CONTENT_TYPE" => "application/json", "rack.input" => body, lint: true)
3737

3838
expect(response.status).to eq(200)
39-
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))
39+
40+
if RUBY_VERSION < "3.4"
41+
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))
42+
else
43+
expect(response.body).to eq(%({published: "true", id: "23"}))
44+
end
4045
end
4146

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

4752
expect(response.status).to eq(200)
48-
expect(response.body).to eq(%({:id=>"23"}))
53+
54+
if RUBY_VERSION < "3.4"
55+
expect(response.body).to eq(%({:id=>"23"}))
56+
else
57+
expect(response.body).to eq(%({id: "23"}))
58+
end
4959
end
5060

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

5565
expect(response.status).to eq(200)
56-
expect(response.body).to eq(%({:_=>["alpha", "beta"], :id=>"23"}))
66+
67+
if RUBY_VERSION < "3.4"
68+
expect(response.body).to eq(%({:_=>["alpha", "beta"], :id=>"23"}))
69+
else
70+
expect(response.body).to eq(%({_: ["alpha", "beta"], id: "23"}))
71+
end
5772
end
5873

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

6479
expect(response.status).to eq(200)
65-
expect(response.body).to eq(%({:json_class=>"Foo", :id=>"23"}))
80+
81+
if RUBY_VERSION < "3.4"
82+
expect(response.body).to eq(%({:json_class=>"Foo", :id=>"23"}))
83+
else
84+
expect(response.body).to eq(%({json_class: "Foo", id: "23"}))
85+
end
6686
end
6787

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

7393
expect(response.status).to eq(200)
74-
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))
94+
95+
if RUBY_VERSION < "3.4"
96+
expect(response.body).to eq(%({:published=>"true", :id=>"23"}))
97+
else
98+
expect(response.body).to eq(%({published: "true", id: "23"}))
99+
end
75100
end
76101
end
77102
end
@@ -82,15 +107,25 @@
82107
response = @app.patch("/authors/23", "CONTENT_TYPE" => "application/xml", "rack.input" => body, lint: true)
83108

84109
expect(response.status).to eq(200)
85-
expect(response.body).to eq(%({:name=>"LG", :id=>"23"}))
110+
111+
if RUBY_VERSION < "3.4"
112+
expect(response.body).to eq(%({:name=>"LG", :id=>"23"}))
113+
else
114+
expect(response.body).to eq(%({name: "LG", id: "23"}))
115+
end
86116
end
87117

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

92122
expect(response.status).to eq(200)
93-
expect(response.body).to eq(%({:name=>"MGF", :id=>"15"}))
123+
124+
if RUBY_VERSION < "3.4"
125+
expect(response.body).to eq(%({:name=>"MGF", :id=>"15"}))
126+
else
127+
expect(response.body).to eq(%({name: "MGF", id: "15"}))
128+
end
94129
end
95130
end
96131
end

0 commit comments

Comments
 (0)