add closed? method on Stream object to inspect the object's open/close state

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
This commit is contained in:
Anurag Priyam 2012-06-24 12:50:33 +05:30
parent 8adecc0968
commit cc8502f62b
2 changed files with 11 additions and 0 deletions

View File

@ -332,6 +332,10 @@ module Sinatra
end
alias errback callback
def closed?
@closed
end
end
# Allows to start sending data to the client even though later parts of

View File

@ -139,4 +139,11 @@ class StreamingTest < Test::Unit::TestCase
get '/'
assert ran
end
it 'has a public interface to inspect its open/closed state' do
stream = Stream.new(Stream) { |out| out << :foo }
assert !stream.closed?
stream.close
assert stream.closed?
end
end