diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-01-14 13:59:15 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-01-14 14:08:47 -0800 |
commit | e4f738709482d95e49552f7ddfda800e1b4a6baf (patch) | |
tree | 5fabcfbbf639b854a1ac03d03894261af08bf3e9 /test/test_clogger_to_path.rb | |
parent | 63521b4c70a1aff89049abf2ba224114e97f62ac (diff) | |
download | clogger-e4f738709482d95e49552f7ddfda800e1b4a6baf.tar.gz |
We can just make Clogger#respond_to? smarter and forward everything except :close to the body we're proxying.
Diffstat (limited to 'test/test_clogger_to_path.rb')
-rw-r--r-- | test/test_clogger_to_path.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/test/test_clogger_to_path.rb b/test/test_clogger_to_path.rb index b25ec46..00767dc 100644 --- a/test/test_clogger_to_path.rb +++ b/test/test_clogger_to_path.rb @@ -31,6 +31,14 @@ class TestCloggerToPath < Test::Unit::TestCase } end + def check_body(body) + assert body.respond_to?(:to_path) + assert body.respond_to?("to_path") + + assert ! body.respond_to?(:to_Path) + assert ! body.respond_to?("to_Path") + end + def test_wraps_to_path logger = StringIO.new tmp = Tempfile.new('') @@ -49,8 +57,8 @@ class TestCloggerToPath < Test::Unit::TestCase end.to_app status, headers, body = app.call(@req) - assert_instance_of(Clogger::ToPath, body) - assert body.respond_to?(:to_path) + assert_instance_of(Clogger, body) + check_body(body) assert logger.string.empty? assert_equal tmp.path, body.to_path body.close @@ -76,8 +84,8 @@ class TestCloggerToPath < Test::Unit::TestCase end.to_app status, headers, body = app.call(@req) - assert_instance_of(Clogger::ToPath, body) - assert body.respond_to?(:to_path) + assert_instance_of(Clogger, body) + check_body(body) assert logger.string.empty? assert_equal "/dev/fd/#{tmp.fileno}", body.to_path body.close @@ -109,8 +117,9 @@ class TestCloggerToPath < Test::Unit::TestCase end.to_app status, headers, body = app.call(@req) - assert_instance_of(Clogger::ToPath, body) - assert body.respond_to?(:to_path) + assert_instance_of(Clogger, body) + check_body(body) + body.to_path assert_kind_of IO, tmp.instance_variable_get(:@to_io_called) assert logger.string.empty? @@ -135,6 +144,8 @@ class TestCloggerToPath < Test::Unit::TestCase end.to_app status, headers, body = app.call(@req) assert_instance_of(Clogger, body) + assert ! body.respond_to?(:to_path) + assert ! body.respond_to?("to_path") assert logger.string.empty? body.close assert ! logger.string.empty? |