From 2e750d9afeaaed35269fbdbbcd380beb5313e921 Mon Sep 17 00:00:00 2001 From: Anorlondo Date: Sun, 29 Jan 2017 16:43:41 +0900 Subject: [PATCH] allow symbol access to cookies --- lib/rack/test/cookie_jar.rb | 2 +- spec/rack/test/cookie_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rack/test/cookie_jar.rb b/lib/rack/test/cookie_jar.rb index 888729fd..c9fe035e 100644 --- a/lib/rack/test/cookie_jar.rb +++ b/lib/rack/test/cookie_jar.rb @@ -120,7 +120,7 @@ def initialize(cookies = [], default_host = DEFAULT_HOST) def [](name) cookies = hash_for(nil) # TODO: Should be case insensitive - cookies[name] && cookies[name].value + cookies[name.to_s] && cookies[name.to_s].value end def []=(name, value) diff --git a/spec/rack/test/cookie_spec.rb b/spec/rack/test/cookie_spec.rb index 7b1f69e3..ba69b0ac 100644 --- a/spec/rack/test/cookie_spec.rb +++ b/spec/rack/test/cookie_spec.rb @@ -43,6 +43,12 @@ expect(jar["abcd"]).to eq(nil) end + it "allow symbol access" do + jar = Rack::Test::CookieJar.new + jar["value"] = "foo;abc" + jar[:value].should == "foo;abc" + end + it "doesn't send cookies with the wrong domain" do get "http://www.example.com/cookies/set", "value" => "1" get "http://www.other.example/cookies/show"