mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Test compatibility with a YAML file saved by Mechanize::Cookie.
This commit is contained in:
parent
d44218c2e2
commit
8e40fc3028
3 changed files with 131 additions and 0 deletions
|
|
@ -19,3 +19,7 @@ module Enumerable
|
|||
result
|
||||
end
|
||||
end
|
||||
|
||||
def test_file(filename)
|
||||
File.expand_path(filename, File.dirname(__FILE__))
|
||||
end
|
||||
|
|
|
|||
101
test/mechanize.yml
Normal file
101
test/mechanize.yml
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
---
|
||||
google.com:
|
||||
/:
|
||||
PREF: !ruby/object:Mechanize::Cookie
|
||||
version: 0
|
||||
port:
|
||||
discard:
|
||||
comment_url:
|
||||
expires: Tue, 24 Mar 2065 08:20:15 GMT
|
||||
max_age:
|
||||
comment:
|
||||
secure: false
|
||||
path: /
|
||||
domain: google.com
|
||||
accessed_at: 2013-03-24 17:20:15.822619000 +09:00
|
||||
created_at: 2013-03-24 17:20:15.822619000 +09:00
|
||||
name: PREF
|
||||
value: ID=7571a59c059e09db:FF=0:TM=1364199615:LM=1364199615:S=BxUqnqPrchd2cVmC
|
||||
for_domain: true
|
||||
domain_name: !ruby/object:DomainName
|
||||
ipaddr:
|
||||
hostname: google.com
|
||||
uri_host: google.com
|
||||
tld: com
|
||||
canonical_tld_p: true
|
||||
domain: google.com
|
||||
session: false
|
||||
NID: !ruby/object:Mechanize::Cookie
|
||||
version: 0
|
||||
port:
|
||||
discard:
|
||||
comment_url:
|
||||
expires: Sun, 23 Sep 2063 08:20:15 GMT
|
||||
max_age:
|
||||
comment:
|
||||
secure: false
|
||||
path: /
|
||||
domain: google.com
|
||||
accessed_at: 2013-03-24 17:20:15.828434000 +09:00
|
||||
created_at: 2013-03-24 17:20:15.828434000 +09:00
|
||||
name: NID
|
||||
value: 67=Kn2osS6wOzILpl7sCM1QIDmGg2VESBiwCyt6zx4vOVSWKOYDlwGIpgIGrpD8FpkbS9eqizo3QWFa5YkOygnCF6vRIQpbvlTxWB2Hq1Oo-qXWy0317yCqQ-B25eJLfUcC
|
||||
for_domain: true
|
||||
domain_name: !ruby/object:DomainName
|
||||
ipaddr:
|
||||
hostname: google.com
|
||||
uri_host: google.com
|
||||
tld: com
|
||||
canonical_tld_p: true
|
||||
domain: google.com
|
||||
session: false
|
||||
google.co.jp:
|
||||
/:
|
||||
PREF: !ruby/object:Mechanize::Cookie
|
||||
version: 0
|
||||
port:
|
||||
discard:
|
||||
comment_url:
|
||||
expires: Tue, 24 Mar 2065 08:20:16 GMT
|
||||
max_age:
|
||||
comment:
|
||||
secure: false
|
||||
path: /
|
||||
domain: google.co.jp
|
||||
accessed_at: 2013-03-24 17:20:17.136581000 +09:00
|
||||
created_at: 2013-03-24 17:20:17.136581000 +09:00
|
||||
name: PREF
|
||||
value: ID=cb25dd1567d8b5c8:FF=0:TM=1364199616:LM=1364199616:S=c3PbhRq79Wo5T_vV
|
||||
for_domain: true
|
||||
domain_name: !ruby/object:DomainName
|
||||
ipaddr:
|
||||
hostname: google.co.jp
|
||||
uri_host: google.co.jp
|
||||
tld: jp
|
||||
canonical_tld_p: true
|
||||
domain: google.co.jp
|
||||
session: false
|
||||
NID: !ruby/object:Mechanize::Cookie
|
||||
version: 0
|
||||
port:
|
||||
discard:
|
||||
comment_url:
|
||||
expires: Sun, 23 Sep 2063 08:20:16 GMT
|
||||
max_age:
|
||||
comment:
|
||||
secure: false
|
||||
path: /
|
||||
domain: google.co.jp
|
||||
accessed_at: 2013-03-24 17:20:17.139782000 +09:00
|
||||
created_at: 2013-03-24 17:20:17.139782000 +09:00
|
||||
name: NID
|
||||
value: 67=GS7P-68zgm_KRA0e0dpN_XbYpmw9uBDe56qUeoCGiSRTahsM7dtOBCKfCoIFRKlzSuOiwJQdIZNpwv3DSXQNHXDKltucgfv2qkHlGeoj8-5VlowPXLLesz2VIpLOLw-a
|
||||
for_domain: true
|
||||
domain_name: !ruby/object:DomainName
|
||||
ipaddr:
|
||||
hostname: google.co.jp
|
||||
uri_host: google.co.jp
|
||||
tld: jp
|
||||
canonical_tld_p: true
|
||||
domain: google.co.jp
|
||||
session: false
|
||||
|
|
@ -505,6 +505,32 @@ module TestHTTPCookieJar
|
|||
assert_equal(5, @jar.cookies(url).length)
|
||||
end
|
||||
|
||||
def test_load_yaml_mechanize
|
||||
@jar.load(test_file('mechanize.yml'), :yaml)
|
||||
|
||||
assert_equal 4, @jar.to_a.size
|
||||
|
||||
com_nid, com_pref = @jar.cookies('http://www.google.com/')
|
||||
|
||||
assert_equal 'NID', com_nid.name
|
||||
assert_equal 'Sun, 23 Sep 2063 08:20:15 GMT', com_nid.expires.httpdate
|
||||
assert_equal 'google.com', com_nid.domain_name.hostname
|
||||
|
||||
assert_equal 'PREF', com_pref.name
|
||||
assert_equal 'Tue, 24 Mar 2065 08:20:15 GMT', com_pref.expires.httpdate
|
||||
assert_equal 'google.com', com_pref.domain_name.hostname
|
||||
|
||||
cojp_nid, cojp_pref = @jar.cookies('http://www.google.co.jp/')
|
||||
|
||||
assert_equal 'NID', cojp_nid.name
|
||||
assert_equal 'Sun, 23 Sep 2063 08:20:16 GMT', cojp_nid.expires.httpdate
|
||||
assert_equal 'google.co.jp', cojp_nid.domain_name.hostname
|
||||
|
||||
assert_equal 'PREF', cojp_pref.name
|
||||
assert_equal 'Tue, 24 Mar 2065 08:20:16 GMT', cojp_pref.expires.httpdate
|
||||
assert_equal 'google.co.jp', cojp_pref.domain_name.hostname
|
||||
end
|
||||
|
||||
def test_expire_cookies
|
||||
url = URI 'http://rubyforge.org/'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue