Skip to content

Commit ea6de47

Browse files
committedMar 18, 2018
feat: do not create reports/pacts/help.md when executing verify from a wrapper language
1 parent ceb1258 commit ea6de47

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed
 

‎lib/pact/provider/pact_spec_runner.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def configure_rspec
9090
# For the Pact::Provider::RSpec::PactBrokerFormatter
9191
Pact.provider_world.pact_sources = pact_sources
9292
jsons = pact_jsons
93+
executing_with_ruby = executing_with_ruby?
9394

9495
config.after(:suite) do | suite |
95-
Pact::Provider::Help::Write.call(jsons)
96+
Pact::Provider::Help::Write.call(jsons) if executing_with_ruby
9697
end
97-
9898
end
9999

100100
def run_specs
@@ -152,12 +152,15 @@ def class_exists? name
152152
false
153153
end
154154

155+
def executing_with_ruby?
156+
ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
157+
end
158+
155159
class NoConfigurationOptions
156160
def method_missing(method, *args, &block)
157161
# Do nothing!
158162
end
159163
end
160-
161164
end
162165
end
163166
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
RSpec.describe "executing pact verify" do
2+
let(:command) { "bundle exec rake pact:verify:test_app:fail > /dev/null" }
3+
let(:reports_dir) { 'spec_reports' } # The config for this is in spec/support/pact_helper.rb
4+
5+
before do
6+
FileUtils.rm_rf reports_dir
7+
end
8+
9+
after do
10+
FileUtils.rm_rf reports_dir
11+
end
12+
13+
context "from ruby" do
14+
it "creates a reports dir" do
15+
system({}, command)
16+
expect(File.exist?(reports_dir)).to be true
17+
end
18+
end
19+
20+
context "with a wrapper language" do
21+
it "does not create a reports dir" do
22+
system({'PACT_EXECUTING_LANGUAGE' => 'foo'}, command)
23+
24+
expect(File.exist?(reports_dir)).to be false
25+
end
26+
end
27+
end

‎spec/support/pact_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def call env
2222
Pact.configure do | config |
2323
config.logger.level = Logger::DEBUG
2424
config.diff_formatter = :unix
25+
config.reports_dir = 'spec_reports'
2526
end
2627

2728
Pact.service_provider "Some Provider" do

0 commit comments

Comments
 (0)