Skip to content
Browse files

pending spec to demonstrate how cookie jar does not comply to the coo…

…kie spec

Relevant spec is RFC 2109, section 4.3.1: Interpreting Set-Cookie:

"Path: Defaults to the path of the request URL that generated the
Set-Cookie response, up to, but not including, the right-most /."

Rack/test strips the entire final component of the URL instead of just
the right-most "/".
  • Loading branch information...
1 parent 0c1434e commit cab8eb929b45d9e32474fad1b6806c2ab8f6bea8 @noahd1 noahd1 committed with
Showing with 21 additions and 0 deletions.
  1. +11 −0 spec/fixtures/fake_app.rb
  2. +10 −0 spec/rack/test/cookie_spec.rb
View
11 spec/fixtures/fake_app.rb
@@ -55,6 +55,17 @@ class FakeApp < Sinatra::Base
"Set"
end
+ post "/cookies/default-path" do
+ raise if params["value"].nil?
+
+ response.set_cookie "simple", params["value"]
+ "Set"
+ end
+
+ get "/cookies/default-path" do
+ response.cookies.inspect
+ end
+
get "/cookies/delete" do
response.delete_cookie "value"
end
View
10 spec/rack/test/cookie_spec.rb
@@ -20,6 +20,16 @@
last_request.cookies.should == {}
end
+ it "cookie path defaults to the uri of the document that was requested" do
+ pending "See issue rack-test github issue #50" do
+ post "/cookies/default-path", "value" => "cookie"
+ get "/cookies/default-path"
+ check last_request.cookies.should == { "simple"=>"cookie" }
+ get "/cookies/show"
+ check last_request.cookies.should == { }
+ end
+ end
+
it "escapes cookie values" do
jar = Rack::Test::CookieJar.new
jar["value"] = "foo;abc"

0 comments on commit cab8eb9

Please sign in to comment.
Something went wrong with that request. Please try again.