diff --git a/lib/pact_broker/client/hal/http_client.rb b/lib/pact_broker/client/hal/http_client.rb index 42440af0..732ddf2d 100644 --- a/lib/pact_broker/client/hal/http_client.rb +++ b/lib/pact_broker/client/hal/http_client.rb @@ -4,11 +4,12 @@ module PactBroker module Client module Hal class HttpClient - attr_accessor :username, :password + attr_reader :username, :password, :verbose def initialize options @username = options[:username] @password = options[:password] + @verbose = options[:verbose] end def get href, params = {}, headers = {} @@ -44,7 +45,9 @@ def create_request uri, http_method, body = nil, headers = {} def perform_request request, uri options = {:use_ssl => uri.scheme == 'https'} response = Retry.until_true do - Net::HTTP.start(uri.host, uri.port, :ENV, options) do |http| + http = Net::HTTP.new(uri.host, uri.port, :ENV, options) + http.set_debug_output($stderr) if verbose + http.start do |http| http.request request end end diff --git a/spec/lib/pact_broker/client/hal/http_client_spec.rb b/spec/lib/pact_broker/client/hal/http_client_spec.rb index 9f7840d1..50d0554f 100644 --- a/spec/lib/pact_broker/client/hal/http_client_spec.rb +++ b/spec/lib/pact_broker/client/hal/http_client_spec.rb @@ -3,12 +3,11 @@ module PactBroker::Client module Hal describe HttpClient do - before do allow(Retry).to receive(:until_true) { |&block| block.call } end - subject { HttpClient.new(username: 'foo', password: 'bar' ) } + subject { HttpClient.new(username: 'foo', password: 'bar') } describe "get" do let!(:request) do