lib/pact/mock_service/client.rb in pact-mock_service-2.12.0 vs lib/pact/mock_service/client.rb in pact-mock_service-3.0.0

- old
+ new

@@ -11,12 +11,12 @@ class Client MOCK_SERVICE_ADMINISTRATON_HEADERS = {'X-Pact-Mock-Service' => 'true'} - def initialize port - @http = Net::HTTP.new('localhost', port) + def initialize port, host = 'localhost' + @http = Net::HTTP.new(host, port) end def verify example_description response = http.request_get("/interactions/verification?example_description=#{CGI.escape(example_description)}", MOCK_SERVICE_ADMINISTRATON_HEADERS) raise VerificationFailedError.new("\e[31m#{response.body}\e[m") unless response.is_a? Net::HTTPSuccess @@ -44,11 +44,12 @@ MOCK_SERVICE_ADMINISTRATON_HEADERS.merge("Content-Type" => "application/json") ) raise AddInteractionError.new("\e[31m#{response.body}\e[m") unless response.is_a? Net::HTTPSuccess end - def self.clear_interactions port, example_description - Net::HTTP.new("localhost", port).delete("/interactions?example_description=#{CGI.escape(example_description)}", MOCK_SERVICE_ADMINISTRATON_HEADERS) + def self.clear_interactions mock_service_base_url, example_description + uri = URI(mock_service_base_url) + Net::HTTP.new(uri.host, uri.port).delete("/interactions?example_description=#{CGI.escape(example_description)}", MOCK_SERVICE_ADMINISTRATON_HEADERS) end def write_pact pacticipant_details response = http.request_post("/pact", pacticipant_details.to_json, MOCK_SERVICE_ADMINISTRATON_HEADERS.merge("Content-Type" => "application/json")) raise WritePactError.new("\e[31m#{response.body}\e[m") unless response.is_a? Net::HTTPSuccess