spec/plugin/cookies_spec.rb in roda-2.23.0 vs spec/plugin/cookies_spec.rb in roda-2.24.0

- old
+ new

@@ -20,6 +20,32 @@ end header('Set-Cookie').must_match(/foo=; (max-age=0; )?expires=Thu, 01[ -]Jan[ -]1970 00:00:00 (-0000|GMT)/) body.must_equal 'Hello' end + + it "should pass default cookie options when setting" do + app.plugin :cookies, :path => '/foo' + app.route { response.set_cookie("foo", "bar") } + header('Set-Cookie').must_equal "foo=bar; path=/foo" + + app.route { response.set_cookie("foo", :value=>"bar", :path=>'/baz') } + header('Set-Cookie').must_equal "foo=bar; path=/baz" + end + + it "should pass default cookie options when deleting" do + app.plugin :cookies, :domain => 'example.com' + app.route { response.delete_cookie("foo") } + header('Set-Cookie').must_match(/foo=; domain=example.com; (max-age=0; )?expires=Thu, 01[ -]Jan[ -]1970 00:00:00 (-0000|GMT)/) + + app.route { response.delete_cookie("foo", :domain=>'bar.com') } + header('Set-Cookie').must_match(/foo=; domain=bar.com; (max-age=0; )?expires=Thu, 01[ -]Jan[ -]1970 00:00:00 (-0000|GMT)/) + end + + it "should not override existing default cookie options" do + app.plugin :cookies, :path => '/foo' + app.plugin :cookies + app.route { response.set_cookie("foo", "bar") } + + header('Set-Cookie').must_equal "foo=bar; path=/foo" + end end