diff --git a/test/test_http_cookie.rb b/test/test_http_cookie.rb index d6a0a7c..c1e9c92 100644 --- a/test/test_http_cookie.rb +++ b/test/test_http_cookie.rb @@ -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('; ') diff --git a/test/test_http_cookie_jar.rb b/test/test_http_cookie_jar.rb index fc49db1..73d7a8e 100644 --- a/test/test_http_cookie_jar.rb +++ b/test/test_http_cookie_jar.rb @@ -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/'