test/spec_body_proxy.rb in rack-1.4.0 vs test/spec_body_proxy.rb in rack-1.4.1

- old
+ new

@@ -1,6 +1,7 @@ require 'rack/body_proxy' +require 'stringio' describe Rack::BodyProxy do should 'call each on the wrapped body' do called = false proxy = Rack::BodyProxy.new(['foo']) { } @@ -27,9 +28,25 @@ should 'call the passed block on close' do called = false proxy = Rack::BodyProxy.new([]) { called = true } called.should.equal false proxy.close + called.should.equal true + end + + should 'call the passed block on close even if there is an exception' do + object = Object.new + def object.close() raise "No!" end + called = false + + begin + proxy = Rack::BodyProxy.new(object) { called = true } + called.should.equal false + proxy.close + rescue RuntimeError => e + end + + raise "Expected exception to have been raised" unless e called.should.equal true end should 'not close more than one time' do count = 0