diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-06 12:03:11 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-06 13:32:07 -0700 |
commit | 485fe222d304c9a795141532596b0575c3d2e6ea (patch) | |
tree | 99543800e26f40898668410f204c1e532161c44e /test | |
parent | 2ca88db578a4b9143a5dfaa66ce38b9463e7e166 (diff) | |
download | clogger-485fe222d304c9a795141532596b0575c3d2e6ea.tar.gz |
Rack::Lint will be relaxed in the next version to allow subclasses of String and Hash objects, so ensure we're good to go when the next version of Rack hits.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_clogger.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 23d6e58..215256c 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -7,6 +7,11 @@ require "stringio" require "rack" require "clogger" + +# used to test subclasses +class FooString < String +end + class TestClogger < Test::Unit::TestCase include Clogger::Format @@ -392,6 +397,41 @@ class TestClogger < Test::Unit::TestCase assert_nothing_raised { cl.call(@req) } end + def test_subclass_hash + str = StringIO.new + req = Rack::Utils::HeaderHash.new(@req) + app = lambda { |env| [302, [ %w(a) ], []] } + cl = Clogger.new(app, :logger => str, :format => Rack_1_0) + assert_nothing_raised { cl.call(req).last.each {} } + assert str.size > 0 + end + + def test_subclassed_string_req + str = StringIO.new + req = {} + @req.each { |key,value| + req[FooString.new(key)] = value.kind_of?(String) ? + FooString.new(value) : value + } + app = lambda { |env| [302, [ %w(a) ], []] } + cl = Clogger.new(app, :logger => str, :format => Rack_1_0) + assert_nothing_raised { cl.call(req).last.each {} } + assert str.size > 0 + end + + def test_subclassed_string_in_body + str = StringIO.new + body = "hello" + r = nil + app = lambda { |env| [302, [ %w(a) ], [FooString.new(body)]] } + cl = Clogger.new(app, :logger => str, :format => '$body_bytes_sent') + assert_nothing_raised { cl.call(@req).last.each { |x| r = x } } + assert str.size > 0 + assert_equal body.size.to_s << "\n", str.string + assert_equal r, body + assert r.object_id != body.object_id + end + def test_http_09_request str = StringIO.new app = lambda { |env| [302, [ %w(a) ], []] } |