From f1a2cd483e61f445145a72e83104e947aad09563 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 16 Mar 2018 08:41:22 +1100 Subject: [PATCH] feat: do not create reports/pacts/help.md when executing verify from a wrapper language --- lib/pact/provider/pact_spec_runner.rb | 9 ++++--- ...uting_verify_from_wrapper_language_spec.rb | 27 +++++++++++++++++++ spec/support/pact_helper.rb | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 spec/integration/executing_verify_from_wrapper_language_spec.rb diff --git a/lib/pact/provider/pact_spec_runner.rb b/lib/pact/provider/pact_spec_runner.rb index 7e1cff57..5c9c4dd0 100644 --- a/lib/pact/provider/pact_spec_runner.rb +++ b/lib/pact/provider/pact_spec_runner.rb @@ -90,11 +90,11 @@ def configure_rspec # For the Pact::Provider::RSpec::PactBrokerFormatter Pact.provider_world.pact_sources = pact_sources jsons = pact_jsons + executing_with_ruby = executing_with_ruby? config.after(:suite) do | suite | - Pact::Provider::Help::Write.call(jsons) + Pact::Provider::Help::Write.call(jsons) if executing_with_ruby end - end def run_specs @@ -152,12 +152,15 @@ def class_exists? name false end + def executing_with_ruby? + ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby' + end + class NoConfigurationOptions def method_missing(method, *args, &block) # Do nothing! end end - end end end diff --git a/spec/integration/executing_verify_from_wrapper_language_spec.rb b/spec/integration/executing_verify_from_wrapper_language_spec.rb new file mode 100644 index 00000000..7853232e --- /dev/null +++ b/spec/integration/executing_verify_from_wrapper_language_spec.rb @@ -0,0 +1,27 @@ +RSpec.describe "executing pact verify" do + let(:command) { "bundle exec rake pact:verify:test_app:fail > /dev/null" } + let(:reports_dir) { 'spec_reports' } # The config for this is in spec/support/pact_helper.rb + + before do + FileUtils.rm_rf reports_dir + end + + after do + FileUtils.rm_rf reports_dir + end + + context "from ruby" do + it "creates a reports dir" do + system({}, command) + expect(File.exist?(reports_dir)).to be true + end + end + + context "with a wrapper language" do + it "does not create a reports dir" do + system({'PACT_EXECUTING_LANGUAGE' => 'foo'}, command) + + expect(File.exist?(reports_dir)).to be false + end + end +end diff --git a/spec/support/pact_helper.rb b/spec/support/pact_helper.rb index 8300b722..01743cff 100644 --- a/spec/support/pact_helper.rb +++ b/spec/support/pact_helper.rb @@ -22,6 +22,7 @@ def call env Pact.configure do | config | config.logger.level = Logger::DEBUG config.diff_formatter = :unix + config.reports_dir = 'spec_reports' end Pact.service_provider "Some Provider" do