File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ def to_h
2424 cookies . map { |cookie | [ cookie . name , cookie ] } . to_h
2525 end
2626
27+ # Serializes the `cookie` header by joining individual cookie strings with semicolons.
28+ def to_s
29+ join ( ";" )
30+ end
31+
2732 # Whether this header is acceptable in HTTP trailers.
2833 # Cookie headers should not appear in trailers as they contain state information needed early in processing.
2934 # @returns [Boolean] `false`, as cookie headers are needed during initial request processing.
Original file line number Diff line number Diff line change 3232 directives : be == { "path" => "/" , "secure" => true } ,
3333 )
3434 end
35-
36- it "has string representation" do
37- session = cookies [ "session" ]
38- expect ( session . to_s ) . to be == "session=123;path=/;secure"
39- end
4035 end
4136
4237 with "session=abc123; secure" do
5045 )
5146 expect ( session . directives ) . to have_keys ( "secure" )
5247 end
48+ end
49+
50+ with "multiple cookies" do
51+ let ( :header ) do
52+ cookie = subject . new
53+ cookie << "session=abc123"
54+ cookie << "user_id=42"
55+ cookie << "token=xyz789"
56+ cookie
57+ end
5358
54- it "has string representation" do
55- session = cookies [ "session" ]
56- expect ( session . to_s ) . to be == "session=abc123;secure"
59+ it "joins cookies with semicolons without spaces" do
60+ expect ( header . to_s ) . to be == "session=abc123;user_id=42;token=xyz789"
5761 end
5862 end
5963end
You can’t perform that action at this time.
0 commit comments