Sha256: c7aa292574f737bfc5545a7f6bf8a368c50c468a054c6b15016d64714a1782f2
Contents?: true
Size: 911 Bytes
Versions: 21
Compression:
Stored size: 911 Bytes
Contents
require 'timeout' require 'net/http' module Pact module MockService module Server class WaitForServerUp def self.call(port, options = {ssl: false}) tries = 0 responsive = false while !(responsive = responsive?(port, options)) && tries < 100 tries += 1 sleep 1 end raise "Timed out waiting for server to start up on port #{port}" if !responsive end def self.responsive? port, options res = Net::HTTP.start("localhost", port) do |http| request = Net::HTTP::Get.new "http://localhost:#{port}/" request['X-Pact-Mock-Service'] = 'true' response = http.request request end res.code == '200' rescue SystemCallError => e return false rescue EOFError return false end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems