Skip to content

Commit bb93b0d

Browse files
committed
fix: ensure specified value of --pact-specification-version is written in pact file
Fixes: #93
1 parent 96a8c51 commit bb93b0d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

lib/pact/mock_service/run.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def service_options
5959
consumer: options[:consumer],
6060
provider: options[:provider],
6161
cors_enabled: options[:cors],
62-
pact_specification_version: Pact::SpecificationVersion::NIL_VERSION.to_s,
62+
pact_specification_version: options[:pact_specification_version] || Pact::SpecificationVersion::NIL_VERSION.to_s,
6363
pactfile_write_mode: options[:pact_file_write_mode],
6464
stub_pactfile_paths: options[:stub_pactfile_paths]
6565
}

spec/integration/cli_spec.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
before :all do
99
clear_dirs
10-
@pid = start_server 1234
10+
@pid = start_server 1234, "--pact-specification-version 3.0.0"
1111
end
1212

1313
it "starts up and responds with mocked responses" do
@@ -40,9 +40,21 @@
4040
end
4141

4242
it "writes the pact to the specified directory" do
43+
clear_interactions 1234
44+
setup_interaction 1234
45+
invoke_expected_request 1234
4346
expect(File.exist?('tmp/pacts/consumer-provider.json')).to be true
4447
end
4548

49+
it "sets the pact specification version" do
50+
clear_interactions 1234
51+
setup_interaction 1234
52+
invoke_expected_request 1234
53+
54+
write_pact 1234
55+
expect(File.read("tmp/pacts/consumer-provider.json")).to include "3.0.0"
56+
end
57+
4658
after :all do
4759
kill_server @pid
4860
end

spec/support/integration_spec_support.rb

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ def setup_interaction port, interaction = expected_interaction
116116
mock_service_headers
117117
end
118118

119+
def clear_interactions port
120+
Faraday.delete "http://localhost:#{port}/interactions"
121+
end
122+
119123
def setup_another_interaction port
120124
Faraday.post "http://localhost:#{port}/interactions",
121125
another_expected_interaction,

0 commit comments

Comments
 (0)