diff options
author | Thomas Grindinger <thomas@linux-ei28.site> | 2016-04-24 17:22:46 -0500 |
---|---|---|
committer | Thomas Grindinger <thomas@linux-ei28.site> | 2016-04-24 17:22:46 -0500 |
commit | 135fabd315c2624c1b25ced5ad15f7b9daba10cf (patch) | |
tree | 413ab4d9d0adeca60c74909b894a410fcc4105ab | |
parent | f8729c23447af5dfce99a8b93b2995b47a55d178 (diff) | |
download | rack-135fabd315c2624c1b25ced5ad15f7b9daba10cf.tar.gz |
improve fragile webrick test
-rw-r--r-- | test/spec_webrick.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/spec_webrick.rb b/test/spec_webrick.rb index 8e0360d2..9ae6103d 100644 --- a/test/spec_webrick.rb +++ b/test/spec_webrick.rb @@ -17,6 +17,19 @@ describe Rack::Handler::WEBrick do Rack::Lint.new(TestRequest.new) @thread = Thread.new { @server.start } trap(:INT) { @server.shutdown } + @status_thread = Thread.new do + seconds = 10 + wait_time = 0.1 + until is_running? || seconds <= 0 + seconds -= wait_time + sleep wait_time + end + raise "Server never reached status 'Running'" unless is_running? + end + end + + def is_running? + @server.status == :Running end it "respond" do @@ -188,6 +201,7 @@ describe Rack::Handler::WEBrick do end after do + @status_thread.join @server.shutdown @thread.join end |