Skip to content

Commit a7f30d4

Browse files
committed
Add tests for multiple cookies.
1 parent 4834a85 commit a7f30d4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/rack/conform/application.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_echo(env)
3939
end
4040

4141
def test_cookies(env)
42-
cookies = JSON.parse(env['rack.input'].read)
42+
request = Rack::Request.new(env)
43+
cookies = request.cookies
4344

4445
Rack::Response.new.tap do |response|
4546
cookies.each do |key, value|

test/rack/conform/cookies.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def body(headers)
1111
end
1212

1313
it 'can respond with a single cookie' do
14-
response = client.get("/cookies", {}, body({'a' => 1}))
14+
response = client.get("/cookies", [['cookie', 'a=1']])
1515

1616
expect(response.status).to be == 200
1717
expect(response.headers).to have_keys(
@@ -21,8 +21,19 @@ def body(headers)
2121
response&.finish
2222
end
2323

24-
it 'can respond with multiple cookies' do
25-
response = client.get("/cookies", {}, body({'a' => 1, 'b' => 2}))
24+
it 'can respond with multiple combined cookies' do
25+
response = client.get("/cookies", [['cookie', 'a=1;b=2']])
26+
27+
expect(response.status).to be == 200
28+
expect(response.headers).to have_keys(
29+
'set-cookie' => be == ["a=1", "b=2"]
30+
)
31+
ensure
32+
response&.finish
33+
end
34+
35+
it 'can respond with multiple cookie headers' do
36+
response = client.get("/cookies", [['cookie', 'a=1'], ['cookie', 'b=2']])
2637

2738
expect(response.status).to be == 200
2839
expect(response.headers).to have_keys(

0 commit comments

Comments
 (0)