mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Let AbstractStore & AbstractSaver autoloaded and add tests for autoloading.
This commit is contained in:
parent
04950f6796
commit
bafb83fc06
2 changed files with 44 additions and 3 deletions
|
|
@ -6,9 +6,6 @@ require 'http/cookie'
|
||||||
# any particular website.
|
# any particular website.
|
||||||
|
|
||||||
class HTTP::CookieJar
|
class HTTP::CookieJar
|
||||||
require 'http/cookie_jar/abstract_store'
|
|
||||||
require 'http/cookie_jar/abstract_saver'
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def const_missing(name)
|
def const_missing(name)
|
||||||
case name.to_s
|
case name.to_s
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,50 @@ require File.expand_path('helper', File.dirname(__FILE__))
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
module TestHTTPCookieJar
|
module TestHTTPCookieJar
|
||||||
|
class TestAutoloading < Test::Unit::TestCase
|
||||||
|
def test_nonexistent_store
|
||||||
|
assert_raises(NameError) {
|
||||||
|
HTTP::CookieJar::NonexistentStore
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_erroneous_store
|
||||||
|
Dir.mktmpdir { |dir|
|
||||||
|
Dir.mkdir(File.join(dir, 'http'))
|
||||||
|
Dir.mkdir(File.join(dir, 'http', 'cookie_jar'))
|
||||||
|
rb = File.join(dir, 'http', 'cookie_jar', 'erroneous_store.rb')
|
||||||
|
File.open(rb, 'w').close
|
||||||
|
$LOAD_PATH.unshift(dir)
|
||||||
|
|
||||||
|
assert_raises(NameError) {
|
||||||
|
HTTP::CookieJar::ErroneousStore
|
||||||
|
}
|
||||||
|
assert_includes $LOADED_FEATURES, rb
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_nonexistent_saver
|
||||||
|
assert_raises(NameError) {
|
||||||
|
HTTP::CookieJar::NonexistentSaver
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_erroneous_saver
|
||||||
|
Dir.mktmpdir { |dir|
|
||||||
|
Dir.mkdir(File.join(dir, 'http'))
|
||||||
|
Dir.mkdir(File.join(dir, 'http', 'cookie_jar'))
|
||||||
|
rb = File.join(dir, 'http', 'cookie_jar', 'erroneous_saver.rb')
|
||||||
|
File.open(rb, 'w').close
|
||||||
|
$LOAD_PATH.unshift(dir)
|
||||||
|
|
||||||
|
assert_raises(NameError) {
|
||||||
|
HTTP::CookieJar::ErroneousSaver
|
||||||
|
}
|
||||||
|
assert_includes $LOADED_FEATURES, rb
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module CommonTests
|
module CommonTests
|
||||||
def setup(options = nil, options2 = nil)
|
def setup(options = nil, options2 = nil)
|
||||||
default_options = {
|
default_options = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue