Skip to content

Commit

Permalink
fix: ensure specified value of --pact-specification-version is writte…
Browse files Browse the repository at this point in the history
…n in pact file

Fixes: pact-foundation#93
  • Loading branch information
bethesque committed Aug 21, 2018
1 parent 96a8c51 commit bb93b0d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pact/mock_service/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def service_options
consumer: options[:consumer],
provider: options[:provider],
cors_enabled: options[:cors],
pact_specification_version: Pact::SpecificationVersion::NIL_VERSION.to_s,
pact_specification_version: options[:pact_specification_version] || Pact::SpecificationVersion::NIL_VERSION.to_s,
pactfile_write_mode: options[:pact_file_write_mode],
stub_pactfile_paths: options[:stub_pactfile_paths]
}
Expand Down
14 changes: 13 additions & 1 deletion spec/integration/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

before :all do
clear_dirs
@pid = start_server 1234
@pid = start_server 1234, "--pact-specification-version 3.0.0"
end

it "starts up and responds with mocked responses" do
Expand Down Expand Up @@ -40,9 +40,21 @@
end

it "writes the pact to the specified directory" do
clear_interactions 1234
setup_interaction 1234
invoke_expected_request 1234
expect(File.exist?('tmp/pacts/consumer-provider.json')).to be true
end

it "sets the pact specification version" do
clear_interactions 1234
setup_interaction 1234
invoke_expected_request 1234

write_pact 1234
expect(File.read("tmp/pacts/consumer-provider.json")).to include "3.0.0"
end

after :all do
kill_server @pid
end
Expand Down
4 changes: 4 additions & 0 deletions spec/support/integration_spec_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def setup_interaction port, interaction = expected_interaction
mock_service_headers
end

def clear_interactions port
Faraday.delete "http://localhost:#{port}/interactions"
end

def setup_another_interaction port
Faraday.post "http://localhost:#{port}/interactions",
another_expected_interaction,
Expand Down

0 comments on commit bb93b0d

Please sign in to comment.