Sha256: c2b0e895434d92f5a8e966d361de9f536bc91c60645e0da771b4c6cf974482cd
Contents?: true
Size: 549 Bytes
Versions: 11
Compression:
Stored size: 549 Bytes
Contents
require 'socket' require 'timeout' module TestHelpers class ServerDown < Exception; end def get_random_open_port # Using a port of "0" relies on the system to pick an open port. server = TCPServer.new('127.0.0.1', 0) port = server.addr[1] server.close port end def verify_server_up(host) http = HTTPClient.new 4.times do begin http.get(host) return true rescue Errno::ECONNREFUSED sleep 0.5 end end raise ServerDown, "Server failed to start: #{host}" end end
Version data entries
11 entries across 11 versions & 1 rubygems