mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Add tests for #path.
This commit is contained in:
parent
6dda359db1
commit
d47e2fe8ad
1 changed files with 26 additions and 0 deletions
|
|
@ -576,6 +576,32 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_path
|
||||
uri = URI.parse('http://example.com/foo/bar')
|
||||
|
||||
assert_equal '/foo/bar', uri.path
|
||||
|
||||
cookie_str = 'a=b'
|
||||
cookie = HTTP::Cookie.parse(cookie_str, :origin => uri).first
|
||||
assert '/foo/', cookie.path
|
||||
|
||||
cookie_str = 'a=b; path=/foo'
|
||||
cookie = HTTP::Cookie.parse(cookie_str, :origin => uri).first
|
||||
assert '/foo', cookie.path
|
||||
|
||||
uri = URI.parse('http://example.com')
|
||||
|
||||
assert_equal '', uri.path
|
||||
|
||||
cookie_str = 'a=b'
|
||||
cookie = HTTP::Cookie.parse(cookie_str, :origin => uri).first
|
||||
assert '/', cookie.path
|
||||
|
||||
cookie_str = 'a=b; path=/foo'
|
||||
cookie = HTTP::Cookie.parse(cookie_str, :origin => uri).first
|
||||
assert '/foo', cookie.path
|
||||
end
|
||||
|
||||
def test_domain_nil
|
||||
cookie = HTTP::Cookie.parse('a=b').first
|
||||
assert_raises(RuntimeError) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue