Gain more coverage.

This commit is contained in:
Akinori MUSHA 2013-04-14 13:02:04 +09:00
parent 6ec66d11ed
commit 028b77987c
2 changed files with 16 additions and 2 deletions

View file

@ -105,6 +105,12 @@ class TestHTTPCookie < Test::Unit::TestCase
}.size
end
def test_parse_no_name
cookie = '=no-name; path=/'
url = URI.parse('http://www.example.com/')
assert_equal 0, HTTP::Cookie.parse(cookie, url).size
end
def test_parse_weird_cookie
cookie = 'n/a, ASPSESSIONIDCSRRQDQR=FBLDGHPBNDJCPCGNCPAENELB; path=/'
url = URI.parse('http://www.searchinnovation.com/')
@ -425,10 +431,10 @@ class TestHTTPCookie < Test::Unit::TestCase
end
def test_set_cookie_value
url = URI.parse('http://rubyforge.org/')
url = URI.parse('http://rubyforge.org/path/')
['foo=bar', 'foo="bar"', 'foo="ba\"r baz"'].each { |cookie_value|
cookie_params = @cookie_params.merge('secure' => 'secure', 'max-age' => 'Max-Age=1000')
cookie_params = @cookie_params.merge('path' => '/path/', 'secure' => 'secure', 'max-age' => 'Max-Age=1000')
date = Time.at(Time.now.to_i)
cookie_params.keys.combine.each do |keys|
cookie_text = [cookie_value, *keys.map { |key| cookie_params[key] }].join('; ')

View file

@ -321,6 +321,14 @@ module TestHTTPCookieJar
assert_equal(0, @jar.cookies(url).length)
end
def test_save_nonexistent_saver
Dir.mktmpdir { |dir|
assert_raises(ArgumentError) {
@jar.save(File.join(dir, "file"), :nonexistent)
}
}
end
def test_save_cookies_yaml
url = URI 'http://rubyforge.org/'