From ea4759bd274671c90a0eba7c64f181a005b948e8 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Mon, 11 Mar 2013 08:26:27 +0900 Subject: [PATCH] Add a test for <=>. --- test/test_http_cookie.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test_http_cookie.rb b/test/test_http_cookie.rb index e8c2fd5..1354217 100644 --- a/test/test_http_cookie.rb +++ b/test/test_http_cookie.rb @@ -418,6 +418,21 @@ class TestHTTPCookie < Test::Unit::TestCase }.merge(options) end + def test_compare + time = Time.now + cookies = [ + { :created_at => time + 1 }, + { :created_at => time - 1 }, + { :created_at => time }, + { :created_at => time, :path => '/foo/bar/' }, + { :created_at => time, :path => '/foo/' }, + ].map { |attrs| HTTP::Cookie.new(cookie_values(attrs)) } + + assert_equal([3, 4, 1, 2, 0], cookies.sort.map { |i| + cookies.find_index { |j| j.equal?(i) } + }) + end + def test_new_rejects_cookies_that_do_not_contain_an_embedded_dot url = URI 'http://rubyforge.org/'