mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +00:00
test: passing DateTime to Cookie#expires=
This commit is contained in:
parent
d2890896e7
commit
fc422f2378
1 changed files with 15 additions and 1 deletions
|
|
@ -717,8 +717,22 @@ class TestHTTPCookie < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_expiration
|
def test_expiration
|
||||||
cookie = HTTP::Cookie.new(cookie_values)
|
expires = Time.now + 86400
|
||||||
|
cookie = HTTP::Cookie.new(cookie_values(expires: expires))
|
||||||
|
|
||||||
|
assert_equal(expires, cookie.expires)
|
||||||
|
assert_equal false, cookie.expired?
|
||||||
|
assert_equal true, cookie.expired?(cookie.expires + 1)
|
||||||
|
assert_equal false, cookie.expired?(cookie.expires - 1)
|
||||||
|
cookie.expire!
|
||||||
|
assert_equal true, cookie.expired?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_expiration_using_datetime
|
||||||
|
expires = DateTime.now + 1
|
||||||
|
cookie = HTTP::Cookie.new(cookie_values(expires: expires))
|
||||||
|
|
||||||
|
assert_equal(expires.to_time, cookie.expires)
|
||||||
assert_equal false, cookie.expired?
|
assert_equal false, cookie.expired?
|
||||||
assert_equal true, cookie.expired?(cookie.expires + 1)
|
assert_equal true, cookie.expired?(cookie.expires + 1)
|
||||||
assert_equal false, cookie.expired?(cookie.expires - 1)
|
assert_equal false, cookie.expired?(cookie.expires - 1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue