Skip to content

Commit

Permalink
feat: change default pact specification version to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 12, 2017
1 parent 9a67d20 commit 0b36e64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/pact/consumer_contract/consumer_contract_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ConsumerContractWriterError < StandardError; end

class ConsumerContractWriter

DEFAULT_PACT_SPECIFICATION_VERSION = '1.0.0'
DEFAULT_PACT_SPECIFICATION_VERSION = '2.0.0'

include Pact::FileName
include Pact::PactFile
Expand Down
12 changes: 6 additions & 6 deletions lib/pact/mock_service/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CLI < Thor
method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost'
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '2'
method_option :log, aliases: "-l", desc: "File to which to log output"
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
Expand All @@ -38,7 +38,7 @@ def service
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
method_option :log_dir, aliases: "-l", desc: "File to which to log output"
method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '2'
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
method_option :sslcert, desc: "Specify the path to the SSL cert to use when running the service over HTTPS"
Expand All @@ -58,7 +58,7 @@ def control
method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite'
method_option :pid_dir, desc: "PID dir", default: 'tmp/pids'
method_option :log, aliases: "-l", desc: "File to which to log output"
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '2'
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
method_option :sslcert, desc: "Specify the path to the SSL cert to use when running the service over HTTPS"
Expand Down Expand Up @@ -87,7 +87,7 @@ def stop
method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite'
method_option :pid_dir, desc: "PID dir", default: 'tmp/pids'
method_option :log, aliases: "-l", desc: "File to which to log output"
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '2'
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
method_option :sslcert, desc: "Specify the path to the SSL cert to use when running the service over HTTPS"
Expand All @@ -103,7 +103,7 @@ def restart
method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '1234'
method_option :log_dir, aliases: "-l", desc: "File to which to log output", default: "log"
method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '2'
method_option :pid_dir, desc: "PID dir", default: "tmp/pids"
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
Expand All @@ -130,7 +130,7 @@ def control_stop
method_option :log_dir, aliases: "-l", desc: "File to which to log output", default: "log"
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written", default: "."
method_option :pact_file_write_mode, aliases: "-m", desc: PACT_FILE_WRITE_MODE_DESC, type: :string, default: 'overwrite'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '2'
method_option :pid_dir, desc: "PID dir", default: "tmp/pids"
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
Expand Down
1 change: 1 addition & 0 deletions script/example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ bundle exec pact-mock-service service \
--port 1234 \
--consumer Foo \
--provider Bar \
--pact-specification-version 2 \
--pact-dir ./tmp/pacts \
--log ./tmp/bar_mock_service.log &
pid=$!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ module Pact

context "when no pact_specification_version is specified" do
let(:pact_specification_version) { nil }
it "defaults to 1" do
expect(Pact::ConsumerContractDecorator).to receive(:new).with(anything, hash_including(pact_specification_version: '1.0.0')).and_call_original
it "defaults to 2" do
expect(Pact::ConsumerContractDecorator).to receive(:new).with(anything, hash_including(pact_specification_version: '2.0.0')).and_call_original
consumer_contract_writer.write
end
end
Expand Down

0 comments on commit 0b36e64

Please sign in to comment.