Fix <=> so that two cookies of different values are not equal.

This commit is contained in:
Akinori MUSHA 2013-03-12 01:28:45 +09:00
parent ea4759bd27
commit 9d842404e3
2 changed files with 7 additions and 1 deletions

View file

@ -379,7 +379,8 @@ class HTTP::Cookie
# Precedence: 1. longer path 2. older creation
(@name <=> other.name).nonzero? ||
(other.path.length <=> @path.length).nonzero? ||
@created_at <=> other.created_at
(@created_at <=> other.created_at).nonzero? ||
@value <=> other.value
end
include Comparable

View file

@ -433,6 +433,11 @@ class TestHTTPCookie < Test::Unit::TestCase
})
end
def test_equal
assert_not_equal(HTTP::Cookie.new(cookie_values),
HTTP::Cookie.new(cookie_values(:value => 'bar')))
end
def test_new_rejects_cookies_that_do_not_contain_an_embedded_dot
url = URI 'http://rubyforge.org/'