about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-14 13:59:15 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-14 14:08:47 -0800
commite4f738709482d95e49552f7ddfda800e1b4a6baf (patch)
tree5fabcfbbf639b854a1ac03d03894261af08bf3e9 /test
parent63521b4c70a1aff89049abf2ba224114e97f62ac (diff)
downloadclogger-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')
-rw-r--r--test/test_clogger_to_path.rb23
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?