about summary refs log tree commit homepage
path: root/test/test_clogger.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-21 08:53:56 +0000
committerEric Wong <normalperson@yhbt.net>2011-01-21 08:57:07 +0000
commit2c43727f8e689ef5998d773feb4cbb2f58009391 (patch)
treea1f79f5595c0612e45a045fbf78b91fdd90ffa43 /test/test_clogger.rb
parentd3a182dd0238c964ff5191642d53fce3d2e64be9 (diff)
downloadclogger-2c43727f8e689ef5998d773feb4cbb2f58009391.tar.gz
Since we delegated response_to?, we also need to delegate
method_missing to the response body in case there are
non-standard methods defined outside of Rack.
Diffstat (limited to 'test/test_clogger.rb')
-rw-r--r--test/test_clogger.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_clogger.rb b/test/test_clogger.rb
index 40c9190..425a4e1 100644
--- a/test/test_clogger.rb
+++ b/test/test_clogger.rb
@@ -697,4 +697,32 @@ class TestClogger < Test::Unit::TestCase
     status, headers, body = cl.call(@req)
     assert %r!\A\d+/\w+/\d{4}:\d\d:\d\d:\d\d \+0000\n\z! =~ s[0], s.inspect
   end
+
+  def test_method_missing
+    s = []
+    body = []
+    def body.foo_bar(foo)
+      [ foo.to_s ]
+    end
+    def body.noargs
+      :hello
+    end
+    def body.omg(&block)
+      yield :PONIES
+    end
+    app = lambda { |env| [200, [], body ] }
+    cl = Clogger.new(app, :logger => s, :format => '$body_bytes_sent')
+    status, headers, body = cl.call(@req)
+    assert_nothing_raised do
+      body.each { |x| s << x }
+      body.close
+    end
+    assert_equal "0\n", s[0], s.inspect
+    assert_kind_of Clogger, body
+    assert_equal %w(1), body.foo_bar(1)
+    assert_equal :hello, body.noargs
+    body.omg { |x| s << x }
+    assert_equal :PONIES, s[1]
+    assert_equal 2, s.size
+  end
 end