A platform for community discussion. Free, open, simple.
DEV: Prevent HTTP specs from hanging during server cleanup (#45219)
Alan Guo Xiang Tanefdaacf92b0c
diff --git a/spec/lib/final_destination/http_spec.rb b/spec/lib/final_destination/http_spec.rbindex 45f88bda929..b701c94b0e0 100644--- a/spec/lib/final_destination/http_spec.rb+++ b/spec/lib/final_destination/http_spec.rb@@ -37,15 +37,18 @@ describe FinalDestination::HTTP do# A minimal HTTP server on `bind`:<ephemeral> that answers every request with "hi".def with_http_server(bind = "127.0.0.1")+ started = Queue.newserver =WEBrick::HTTPServer.new(BindAddress: bind,Port: 0,Logger: WEBrick::Log.new(File::NULL),AccessLog: [],+ StartCallback: -> { started << true },)server.mount_proc("/") { |_req, res| res.body = "hi" }thread = Thread.new { server.start }+ started.popyield server.config[:Port]ensureserver&.shutdown