Skip to content

Commit

Permalink
feat: do not create reports/pacts/help.md when executing verify from …
Browse files Browse the repository at this point in the history
…a wrapper language
  • Loading branch information
bethesque committed Mar 15, 2018
1 parent fa98102 commit f1a2cd4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/pact/provider/pact_spec_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
27 changes: 27 additions & 0 deletions spec/integration/executing_verify_from_wrapper_language_spec.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions spec/support/pact_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1a2cd4

Please sign in to comment.