diff --git a/lib/pact/provider_verifier/set_up_provider_state.rb b/lib/pact/provider_verifier/set_up_provider_state.rb index 41bd1e9..1674d18 100644 --- a/lib/pact/provider_verifier/set_up_provider_state.rb +++ b/lib/pact/provider_verifier/set_up_provider_state.rb @@ -92,11 +92,15 @@ def add_custom_provider_header request end def check_for_error response - if response.status >= 300 - raise SetUpProviderStateError.new("Error setting up provider state '#{provider_state}' for consumer '#{consumer}' at #{provider_states_setup_url}. response status=#{response.status} response body=#{response.body}") + if response.status >= 300 && !(@options[:enable_pending] == true) + raise SetUpProviderStateError.new(set_up_provider_state_error_message(response)) end end + def set_up_provider_state_error_message(response) + "Error setting up provider state '#{provider_state}' for consumer '#{consumer}' at #{provider_states_setup_url}. response status=#{response.status} response body=#{response.body}" + end + def log_request if verbose? $stdout.puts "DEBUG: Setting up provider state '#{provider_state}' for consumer '#{consumer}' using provider state set up URL #{provider_states_setup_url}" diff --git a/spec/lib/pact/provider_verifier/set_up_provider_state_spec.rb b/spec/lib/pact/provider_verifier/set_up_provider_state_spec.rb index 4efea0c..33652fb 100644 --- a/spec/lib/pact/provider_verifier/set_up_provider_state_spec.rb +++ b/spec/lib/pact/provider_verifier/set_up_provider_state_spec.rb @@ -31,8 +31,23 @@ module ProviderVerifier stub_request(:post, provider_states_setup_url).to_return(status: 500, body: "Some error") end - it "raises an error" do - expect { subject }.to raise_error(SetUpProviderStateError, /500.*Some error/) + context "when enable_pending is not set" do + it "raises an error" do + expect { subject }.to raise_error(SetUpProviderStateError, /500.*Some error/) + end + end + + context "when enable_pending is set" do + let(:options) do + { + params: params, + enable_pending: true, + } + end + + it "does not raise an error" do + expect { subject }.not_to raise_error + end end end