Skip to content

Commit

Permalink
fixup! Contain fibers and open ports in HTTP::Client and HTTP::WebSoc…
Browse files Browse the repository at this point in the history
…ket specs
  • Loading branch information
straight-shoota committed Dec 19, 2018
1 parent 89b00ee commit e0e8e33
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions spec/std/http/client/client_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require "http/server"

private def test_server(host, port, read_time = 0)
server = TCPServer.new(host, port)
server_done = Channel(Nil).new
server_done = Channel(Exception?).new

spawn do
io = server.accept
Expand All @@ -17,7 +17,9 @@ private def test_server(host, port, read_time = 0)
ensure
io.close
end
ensure
rescue exc
server_done.send exc
else
server_done.send nil
end

Expand All @@ -26,7 +28,9 @@ private def test_server(host, port, read_time = 0)
ensure
server.close

server_done.receive
if exc = server_done.receive
raise exc
end
end
end

Expand Down

0 comments on commit e0e8e33

Please sign in to comment.