diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-29 13:17:31 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-29 13:28:10 -0700 |
commit | 9ecded1c91cc88e9c6c3df376bea1713a5ec3d05 (patch) | |
tree | fe7a463daa4c480cf82b1823733a938bc77dcdfd | |
parent | 5097d2cf7359193b16fa31395efe69532a59b1d6 (diff) | |
download | unicorn-9ecded1c91cc88e9c6c3df376bea1713a5ec3d05.tar.gz |
This is in the Rack specification and a good idea. Remind ourselves to prevent file descriptor or other resource leaks in case the body is not an Array.
-rw-r--r-- | test/unit/test_response.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb index 17732fe..203ae4d 100644 --- a/test/unit/test_response.rb +++ b/test/unit/test_response.rb @@ -54,5 +54,15 @@ class ResponseTest < Test::Unit::TestCase assert_match(/^X-Whatever: stuff\r\nX-Whatever: bleh\r\n/, out.string) end -end + def test_body_closed + expect_body = %w(1 2 3 4).join("\n") + body = StringIO.new(expect_body) + body.rewind + out = StringIO.new + HttpResponse.write(out,[200, {}, body]) + assert out.closed? + assert body.closed? + assert_match(expect_body, out.string.split(/\r\n/).last) + end +end |