From 2f7110b32d4de2669842f8aac8338aeed18bc5c9 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 15 Nov 2019 14:33:58 +1100 Subject: [PATCH] fix(verify): exit with status 0 if all pacts are in pending state --- lib/pact/provider/pact_spec_runner.rb | 6 +++++- lib/pact/provider/rspec.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pact/provider/pact_spec_runner.rb b/lib/pact/provider/pact_spec_runner.rb index 7db51560..5e4c9b68 100644 --- a/lib/pact/provider/pact_spec_runner.rb +++ b/lib/pact/provider/pact_spec_runner.rb @@ -91,7 +91,7 @@ def run_specs ::RSpec::Core::CommandLine.new(NoConfigurationOptions.new) .run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream) end - options[:ignore_failures] ? 0 : exit_code + (all_pacts_pending? || options[:ignore_failures]) ? 0 : exit_code end def rspec_runner_options @@ -159,6 +159,10 @@ def ordered_pact_json(pact_json) consumer_contract.to_json end + def all_pacts_pending? + pact_urls.all?{ | pact_url| pact_url.metadata[:pending] } + end + def class_exists? name Kernel.const_get name rescue NameError diff --git a/lib/pact/provider/rspec.rb b/lib/pact/provider/rspec.rb index 61dfed0d..1a7f2a65 100644 --- a/lib/pact/provider/rspec.rb +++ b/lib/pact/provider/rspec.rb @@ -76,7 +76,7 @@ def describe_interaction interaction, options pact_interaction: interaction, pact_interaction_example_description: interaction_description_for_rerun_command(interaction), pact_uri: options[:pact_uri], - pact_ignore_failures: options[:pact_uri].metadata[:pending] + pact_ignore_failures: options[:pact_uri].metadata[:pending] || options[:ignore_failures] } describe description_for(interaction), metadata do