warmup prior to running tests

This commit is contained in:
Sam 2017-07-19 12:04:03 -04:00
parent bf0d70e820
commit 6e3b2cc860
1 changed files with 19 additions and 0 deletions

View File

@ -51,6 +51,25 @@ task "qunit:test", [:timeout] => :environment do |_, args|
cmd += " #{args[:timeout]}"
end
@now = Time.now
def elapsed
Time.now - @now
end
# wait for server to accept connections
require 'net/http'
uri = URI("http://localhost:#{port}/assets/test_helper.js")
puts "Warming up Rails server"
begin
Net::HTTP.get(uri)
rescue Errno::ECONNREFUSED
sleep 1
retry unless elapsed() > 60
puts "Timed out. Can no connect to forked server!"
exit 1
end
puts "Rails server is warmed up"
# wait for server to respond, will exception out on failure
tries = 0
begin