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:
parent
8adecc0968
commit
cc8502f62b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue