Skip to content

Commit bb7977b

Browse files
committed
add doc comment + test for new method
1 parent d8513fe commit bb7977b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/ld-eventsource/client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ def close
190190
end
191191
end
192192

193+
#
194+
# Tests whether the client has been shut down by a call to {Client#close}.
195+
#
196+
# @return [Boolean] true if the client has been shut down
197+
#
193198
def closed?
194199
@stopped.value
195200
end

spec/client_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,19 @@ def send_stream_content(res, content, keep_open:)
426426
end
427427
end
428428
end
429+
430+
it "returns true from closed? when closed" do
431+
with_server do |server|
432+
server.setup_response("/") do |req,res|
433+
send_stream_content(res, "", keep_open: true)
434+
end
435+
436+
with_client(subject.new(server.base_uri)) do |client|
437+
expect(client.closed?).to be(false)
438+
439+
client.close
440+
expect(client.closed?).to be(true)
441+
end
442+
end
443+
end
429444
end

0 commit comments

Comments
 (0)