From 2c43727f8e689ef5998d773feb4cbb2f58009391 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 21 Jan 2011 08:53:56 +0000 Subject: delegate method_missing calls to the response body 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. --- test/test_clogger.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') 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 -- cgit v1.2.3-24-ge0c7