diff --git a/lib/pact/provider/configuration/pact_verification_from_broker.rb b/lib/pact/provider/configuration/pact_verification_from_broker.rb index cf74c769..931fdd7d 100644 --- a/lib/pact/provider/configuration/pact_verification_from_broker.rb +++ b/lib/pact/provider/configuration/pact_verification_from_broker.rb @@ -13,11 +13,12 @@ class PactVerificationFromBroker # in parent scope, it will clash with these ones, # so put an underscore in front of the name to be safer. - attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_basic_auth_options + attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_basic_auth_options, :_verbose def initialize(provider_name) @_provider_name = provider_name @_consumer_version_tags = [] + @_verbose = false end dsl do @@ -29,6 +30,10 @@ def pact_broker_base_url pact_broker_base_url, basic_auth_options = {} def consumer_version_tags consumer_version_tags self._consumer_version_tags = *consumer_version_tags end + + def verbose verbose + self._verbose = verbose + end end def finalize @@ -39,7 +44,7 @@ def finalize private def create_pact_verification - fetch_pacts = Pact::PactBroker::FetchPacts.new(_provider_name, _consumer_version_tags, _pact_broker_base_url, _basic_auth_options) + fetch_pacts = Pact::PactBroker::FetchPacts.new(_provider_name, _consumer_version_tags, _pact_broker_base_url, _basic_auth_options.merge(verbose: _verbose)) Pact.provider_world.add_pact_uri_source fetch_pacts end diff --git a/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb b/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb index f93c5fd6..095beed2 100644 --- a/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb +++ b/spec/lib/pact/provider/configuration/pact_verification_from_broker_spec.rb @@ -25,13 +25,15 @@ module Configuration PactVerificationFromBroker.build(provider_name) do pact_broker_base_url base_url, basic_auth_options consumer_version_tags tags + verbose true end end let(:fetch_pacts) { double('FetchPacts') } + let(:options) { basic_auth_options.merge(verbose: true) } it "creates a instance of Pact::PactBroker::FetchPacts" do - expect(Pact::PactBroker::FetchPacts).to receive(:new).with(provider_name, tags, base_url, basic_auth_options) + expect(Pact::PactBroker::FetchPacts).to receive(:new).with(provider_name, tags, base_url, options) subject end @@ -85,6 +87,21 @@ module Configuration subject end end + + context "when no verbose flag is provided" do + subject do + PactVerificationFromBroker.build(provider_name) do + pact_broker_base_url base_url + end + end + + let(:fetch_pacts) { double('FetchPacts') } + + it "creates an instance of FetchPacts with verbose: false" do + expect(Pact::PactBroker::FetchPacts).to receive(:new).with(anything, anything, anything, hash_including(verbose: false)) + subject + end + end end end end diff --git a/spec/lib/pact/provider/verification_results/publish_spec.rb b/spec/lib/pact/provider/verification_results/publish_spec.rb index 1260163a..15565527 100644 --- a/spec/lib/pact/provider/verification_results/publish_spec.rb +++ b/spec/lib/pact/provider/verification_results/publish_spec.rb @@ -170,7 +170,7 @@ module VerificationResults context "when the connection can't be made" do it "raises a PublicationError error" do - allow(Net::HTTP).to receive(:start).and_raise(SocketError) + allow(Net::HTTP).to receive(:new).and_raise(SocketError) expect{ subject }.to raise_error(PublicationError, /Failed to publish verification/) end end