Permalink
Browse files

call #close on body in mock responses

  • Loading branch information...
rkh committed Jun 9, 2011
1 parent ea72d64 commit 41f085d985009c9de87814f6246b5d91c4230be4
Showing with 9 additions and 0 deletions.
  1. +1 −0 lib/rack/mock.rb
  2. +8 −0 test/spec_mock.rb
View
@@ -154,6 +154,7 @@ def initialize(status, headers, body, errors=StringIO.new(""))
@body_string = nil
super(body, status, headers)
+ body.close if body.respond_to?(:close)
end
def =~(other)
View
@@ -233,6 +233,14 @@
res.errors.should.include "foo"
end
+ should "call close on the original body object" do
+ called = false
+ body = Rack::BodyProxy.new(['hi']) { called = true }
+ called.should.equal false
+ Rack::MockResponse.new(200, {}, body)
+ called.should.equal true
+ end
+
should "optionally make Rack errors fatal" do
lambda {
Rack::MockRequest.new(app).get("/?error=foo", :fatal => true)

0 comments on commit 41f085d

Please sign in to comment.