Commit graph

45 commits

Author SHA1 Message Date
Akinori MUSHA
e9230a00c1 Add tests for MozillaStore#upgrade_database and fix its bugs. 2013-04-16 00:03:03 +09:00
Akinori MUSHA
8e40fc3028 Test compatibility with a YAML file saved by Mechanize::Cookie. 2013-04-15 14:15:46 +09:00
Akinori MUSHA
1a05bb4dd0 Add more tests. 2013-04-14 13:40:49 +09:00
Akinori MUSHA
028b77987c Gain more coverage. 2013-04-14 13:02:04 +09:00
Akinori MUSHA
655fc9eb56 Add tests for the constructor & store. 2013-04-14 12:19:11 +09:00
Akinori MUSHA
c9a8e29202 Fix a typo. 2013-04-14 12:19:10 +09:00
Akinori MUSHA
a1a130f156 CookieJar#parse: Use the block's return values to decide whether to add a cookie. 2013-04-14 12:10:28 +09:00
Akinori MUSHA
6fcc298b80 MozillaStore saves timestamps in seconds, so use a session cookie for testing. 2013-04-13 13:35:54 +09:00
Akinori MUSHA
9fec000a29 Slightly fix the timestamp tests. 2013-04-13 13:27:09 +09:00
Akinori MUSHA
17a3cbc970 Remove an unsupported keyword: session. 2013-04-13 12:57:13 +09:00
Akinori MUSHA
75267e8002 Use assert_send for comparison tests to see what is going on. 2013-04-12 23:18:06 +09:00
Akinori MUSHA
917adc1abb Add a test for Cookie#accessed_at. 2013-04-12 01:25:04 +09:00
Akinori MUSHA
f3b8abdd8e Add CookieJar#delete(). 2013-04-12 01:19:39 +09:00
Akinori MUSHA
ffabb614ad Perform acceptance check in CookieJar#add instead of origin=.
- Cookie#acceptable? is added, which is called by such methods as
  Cookie.parse and CookieJar#add.

- Cookie#origin= no longer raises ArgumentError just because it
  conflicts with the domain.

- Cookie#origin= raises ArgumentError if it is given an object that is
  not URI or string-like.
2013-04-03 17:57:27 +09:00
Akinori MUSHA
2dc17ab7dc Better indentation while test is passing. 2013-03-28 19:24:05 +09:00
Akinori MUSHA
8d7da32cc3 Fully test MozillaStore as well as HashStore. 2013-03-27 02:49:55 +09:00
Akinori MUSHA
d76101722d Catch IndexError instead. 2013-03-27 20:40:56 +09:00
Akinori MUSHA
4ebce92fad Rescue LoadError. 2013-03-27 20:16:05 +09:00
Akinori MUSHA
683141da59 Use :memory: database to save test time. 2013-03-27 19:50:31 +09:00
Akinori MUSHA
eed7e57813 Use the cookie creation time as base time for Max-Age.
Now #expire returns created_at + max_age when expires is nil.

Cookie.parse: the :date keyword is renamed to :created_at, and the
value is set to in parsed cookies via #created_at.

In YAML serialization, #max_age is stored.
2013-03-27 19:50:30 +09:00
Akinori MUSHA
a0ea64da56 CookieJar.new: Pass the store class via a :store keyword. 2013-03-27 17:43:58 +09:00
Akinori MUSHA
6fade20c59 Make GC threshold user specifiable. 2013-03-27 16:10:05 +09:00
Akinori MUSHA
69b3186666 Add MozillaStore. 2013-03-27 16:01:48 +09:00
Akinori MUSHA
bd3ae6c1ae CookiestxtSaver: Hide HttpOnly cookies from old browsers.
This trick is the one that has been used in Mozilla before switching
the cookie database to SQLite.
2013-03-26 15:37:50 +09:00
Akinori MUSHA
8b78e3d1e4 CookiestxtSaver: Prefix the domain field with a dot if the domain flag is on.
The leading dot itself should be meaningless since there is the second
field to tell if the cookie is issued for a domain and that was the
reason I once removed it, but on second thought it doesn't hurt to put
one.
2013-03-26 15:37:50 +09:00
Akinori MUSHA
38f7e98f09 Replace compatibility errors with documentation.
Leave compatibility stuff to Mechanize itself and just keep
http-cookie clean.
2013-03-23 00:27:38 +09:00
Akinori MUSHA
9768154e82 Dir.tmpdir should be mktmpdir here. 2013-03-18 00:39:55 +09:00
Akinori MUSHA
f936d91521 1.8 compatibility: Fix syntax and remove dependency on hash key order. 2013-03-15 12:13:59 +09:00
Akinori MUSHA
b2920eda0f Do not chdir in test. It breaks autoloads since test is run with -Ilib. 2013-03-15 12:12:53 +09:00
Akinori MUSHA
8be03978a0 Make each(uri) not fail if a non-HTTP URL is given.
Fix documents with #each.  The uri argument was not made a keyword
argument.

Guarantee that the +uri+ given to AbstractStore#each() is a URI
object.

Make HashStore#each return self as required.
2013-03-15 11:33:54 +09:00
Akinori MUSHA
b86690cb21 Check if the scheme is http(s) and the host is non-nil in URI. 2013-03-15 11:21:57 +09:00
Akinori MUSHA
c0d5f3a121 Add error messages to make migration from Mechanize::Cookie easier.
Add a section to elaborate on the incompatibilities to README.md.
2013-03-15 05:53:11 +09:00
Akinori MUSHA
8d8f01fa81 Cap the numbers of cookies per domain and cookies total, respectively.
This is implemented in HashStore#cleanup(), which is automatically
called by #add() after every 150 updates.
2013-03-15 04:20:59 +09:00
Akinori MUSHA
1f5eb6bc7f Introduce an abstraction layer for saving (serializing) CookieJar.
CookieJar#save is the new name for the now obsolete #save_as.

CookieJar#save and #load now accept IO-like instead of a filename.

Change the YAML file format, and make #load discard incompatible data.
2013-03-15 04:20:59 +09:00
Akinori MUSHA
fd7450717a Implement HTTP::CookieJar#empty? without an argument. 2013-03-15 04:20:59 +09:00
Akinori MUSHA
91193dace3 Fix saving in the cookies.txt format. Expires values were broken.
Remove duplicate and incomplete tests.
2013-03-15 04:20:58 +09:00
Akinori MUSHA
1731b155e6 HTTP::CookieJar#add: Check if both the domain and path of the cookie are set. 2012-10-22 14:50:49 +09:00
Akinori MUSHA
fdcdae34be Make test_save_and_read_cookiestxt better. 2012-10-22 03:29:32 +09:00
Akinori MUSHA
95c702f99b Rename HTTP::CookieJar#add! to HTTP::CookieJar#add removing the original #add. 2012-10-22 02:39:20 +09:00
Akinori MUSHA
a342680e4e Fix and move some tests from test_http_cookie_jar.rb to test_http_cookie.rb. 2012-10-22 02:38:08 +09:00
Akinori MUSHA
ae4a9d8d40 Make HTTP::Cookie Comparable. 2012-10-22 01:02:00 +09:00
Akinori MUSHA
53e5b270ee Improve test_save_cookies_yaml(). 2012-10-22 00:04:53 +09:00
Akinori MUSHA
aa64d3d98b Rename HTTP::Cookie#clear! to clear. 2012-10-21 23:48:57 +09:00
Akinori MUSHA
2b96f2317d Class name paranoia. 2012-10-14 22:10:44 +09:00
Akinori MUSHA
060fc63c2a Import cookie related stuff from Mechanize. 2012-10-14 18:52:52 +09:00