pact 1.49.2 → 1.51.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbaf27920b084c3e068879eca948ec784ce829ad8779aea73125ee1c5b947218
4
- data.tar.gz: 5e53c5bf61194d1bfa8e768ece8c8bacaf8c9b096b9f4ba8e8bca89ff28749b2
3
+ metadata.gz: 0334b2a6c3b1884ed7ca47e5cc060b97c4ef0bb2b02ce898a34ea2c67e67eba8
4
+ data.tar.gz: 4fa53510c36f9fc791f3282932f697f105b4e9d5ca47c11bf91bd4eb2453bf1f
5
5
  SHA512:
6
- metadata.gz: 62cd377157130e34e4b8b32e9acea4ae28d00e1c89696520e3afb54f3bc534165179045cc21e9eeba41503b49d195dbd5a31f939edfafa2cd20a088304012aa2
7
- data.tar.gz: b16b23ee357139cefcea6ad97cba99779776e9264b3b0d8653e9ab000a5c7f61af8d4e1b0c42b2ffc47ae32bbc464b6a67496be2ab5ffced6bc843fc8143d6e7
6
+ metadata.gz: 03567421b18b621002ba594284c70d4b8b38d34827aa923faf4ac4dab36094e95a232f203b1845aaeb91fd4ce25df912a8566a236182309a4d0b02ed75d32b38
7
+ data.tar.gz: 16155260304a4f7cadf5c43d96f7f0567a157a49dc6f2dba335e2e72506c7772d6f1767216f56c0a951b6efc231a2c6890eb261775ef6d1437797f5c8524b120
@@ -1,3 +1,47 @@
1
+ <a name="v1.51.1"></a>
2
+ ### v1.51.1 (2020-08-12)
3
+
4
+ #### Bug Fixes
5
+
6
+ * update thor dependency (#218) ([bf3ce69](/../../commit/bf3ce69))
7
+ * bump rake dependency per CVE-2020-8130 (#219) ([09feaa6](/../../commit/09feaa6))
8
+
9
+ <a name="v1.51.0"></a>
10
+ ### v1.51.0 (2020-06-24)
11
+
12
+
13
+ #### Features
14
+
15
+ * allow individual interactions to be re-run by setting PACT_BROKER_INTERACTION_ID ([a586d80](/../../commit/a586d80))
16
+
17
+
18
+ <a name="v1.50.1"></a>
19
+ ### v1.50.1 (2020-06-15)
20
+
21
+
22
+ #### Bug Fixes
23
+
24
+ * fix integration with pact-message-ruby (#216) ([d2da13e](/../../commit/d2da13e))
25
+
26
+
27
+ <a name="v1.50.0"></a>
28
+ ### v1.50.0 (2020-04-25)
29
+
30
+
31
+ #### Features
32
+
33
+ * Set expected interactions on mock service but without writing them to pact file (#210) ([14f5327](/../../commit/14f5327))
34
+
35
+
36
+ <a name="v1.49.3"></a>
37
+ ### v1.49.3 (2020-04-22)
38
+
39
+
40
+ #### Bug Fixes
41
+
42
+ * pact selection verification options logging ([9ff59f4](/../../commit/9ff59f4))
43
+
44
+
1
45
  <a name="v1.49.2"></a>
2
46
  ### v1.49.2 (2020-04-08)
3
47
 
@@ -4,6 +4,9 @@ require 'pact/provider/configuration'
4
4
 
5
5
  module Pact
6
6
  class CLI < Thor
7
+ def self.exit_on_failure? # Thor 1.0 deprecation guard
8
+ false
9
+ end
7
10
 
8
11
  desc 'verify', "Verify a pact"
9
12
  method_option :pact_helper, aliases: "-h", desc: "Pact helper file", :required => true
@@ -18,6 +21,8 @@ module Pact
18
21
  default: Pact.configuration.interactions_replay_order
19
22
  method_option :description, aliases: "-d", desc: "Interaction description filter"
20
23
  method_option :provider_state, aliases: "-s", desc: "Provider state filter"
24
+ method_option :interaction_index, type: :numeric, desc: "Index filter"
25
+ method_option :pact_broker_interaction_id, desc: "Pact Broker interaction ID filter"
21
26
  method_option :format, aliases: "-f", banner: "FORMATTER", desc: "RSpec formatter. Defaults to custom Pact formatter. [j]son may also be used."
22
27
  method_option :out, aliases: "-o", banner: "FILE", desc: "Write output to a file instead of $stdout."
23
28
 
@@ -6,8 +6,11 @@ module Pact
6
6
  criteria = {}
7
7
 
8
8
  criteria[:description] = Regexp.new(options[:description]) if options[:description]
9
+ criteria[:_id] = options[:pact_broker_interaction_id] if options[:pact_broker_interaction_id]
10
+ criteria[:index] = options[:interaction_index] if options[:interaction_index]
9
11
 
10
12
  provider_state = options[:provider_state]
13
+
11
14
  if provider_state
12
15
  if provider_state.length == 0
13
16
  criteria[:provider_state] = nil #Allow PACT_PROVIDER_STATE="" to mean no provider state
@@ -25,6 +25,10 @@ module Pact
25
25
  @mock_service_base_url = "http://#{attributes[:host]}:#{attributes[:port]}"
26
26
  end
27
27
 
28
+ def without_writing_to_pact
29
+ interaction_builder.without_writing_to_pact
30
+ end
31
+
28
32
  def given(provider_state)
29
33
  interaction_builder.given(provider_state)
30
34
  end
@@ -13,6 +13,12 @@ module Pact
13
13
  @callback = block
14
14
  end
15
15
 
16
+ def without_writing_to_pact
17
+ interaction.metadata ||= {}
18
+ interaction.metadata[:write_to_pact] = false
19
+ self
20
+ end
21
+
16
22
  def upon_receiving description
17
23
  @interaction.description = description
18
24
  self
@@ -4,10 +4,12 @@ require 'pact/provider/pact_uri'
4
4
  require 'pact/errors'
5
5
  require 'pact/pact_broker/fetch_pacts'
6
6
  require 'pact/pact_broker/notices'
7
+ require 'pact/pact_broker/pact_selection_description'
7
8
 
8
9
  module Pact
9
10
  module PactBroker
10
11
  class FetchPactURIsForVerification
12
+ include PactSelectionDescription
11
13
  attr_reader :provider, :consumer_version_selectors, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
12
14
 
13
15
  PACTS_FOR_VERIFICATION_RELATION = 'beta:provider-pacts-for-verification'.freeze
@@ -84,18 +86,7 @@ module Pact
84
86
  end
85
87
 
86
88
  def log_message
87
- latest = consumer_version_selectors.any? ? "" : "latest "
88
- message = "INFO: Fetching pacts for #{provider} from #{broker_base_url} with the selection criteria: "
89
- if consumer_version_selectors.any?
90
- desc = consumer_version_selectors.collect do |selector|
91
- all_or_latest = selector[:all] ? "all for tag" : "latest for tag"
92
- # TODO support fallback
93
- name = selector[:fallback] ? "#{selector[:tag]} (or #{selector[:fallback]} if not found)" : selector[:tag]
94
- "#{all_or_latest} #{name}"
95
- end.join(", ")
96
- message << ": #{desc}"
97
- end
98
- Pact.configuration.output_stream.puts message
89
+ Pact.configuration.output_stream.puts "INFO: #{pact_selection_description(provider, consumer_version_selectors, options, broker_base_url)}"
99
90
  end
100
91
  end
101
92
  end
@@ -0,0 +1,24 @@
1
+ module Pact
2
+ module PactBroker
3
+ module PactSelectionDescription
4
+ def pact_selection_description(provider, consumer_version_selectors, options, broker_base_url)
5
+ latest = consumer_version_selectors.any? ? "" : "latest "
6
+ message = "Fetching pacts for #{provider} from #{broker_base_url} with the selection criteria: "
7
+ if consumer_version_selectors.any?
8
+ desc = consumer_version_selectors.collect do |selector|
9
+ all_or_latest = !selector[:latest] ? "all for tag" : "latest for tag"
10
+ # TODO support fallback
11
+ fallback = selector[:fallback] || selector[:fallbackTag]
12
+ name = fallback ? "#{selector[:tag]} (or #{fallback} if not found)" : selector[:tag]
13
+ "#{all_or_latest} #{name}"
14
+ end.join(", ")
15
+ if options[:include_wip_pacts_since]
16
+ desc = "#{desc}, work in progress pacts created after #{options[:include_wip_pacts_since]}"
17
+ end
18
+ message << "#{desc}"
19
+ end
20
+ message
21
+ end
22
+ end
23
+ end
24
+ end
@@ -22,6 +22,33 @@ module Pact
22
22
  end
23
23
 
24
24
  dsl do
25
+ def app &block
26
+ self.app_block = block
27
+ end
28
+
29
+ def app_version application_version
30
+ self.application_version = application_version
31
+ end
32
+
33
+ def app_version_tags tags
34
+ self.tags = tags
35
+ end
36
+
37
+ def publish_verification_results publish_verification_results
38
+ self.publish_verification_results = publish_verification_results
39
+ Pact::RSpec.with_rspec_2 do
40
+ Pact.configuration.error_stream.puts "WARN: Publishing of verification results is currently not supported with rspec 2. If you would like this functionality, please feel free to submit a PR!"
41
+ end
42
+ end
43
+
44
+ def honours_pact_with consumer_name, options = {}, &block
45
+ create_pact_verification consumer_name, options, &block
46
+ end
47
+
48
+ def honours_pacts_from_pact_broker &block
49
+ create_pact_verification_from_broker &block
50
+ end
51
+
25
52
  def builder &block
26
53
  self.app_block = lambda { RackToMessageAdapter.new(block) }
27
54
  end
@@ -93,17 +93,32 @@ module Pact
93
93
 
94
94
  def interaction_rerun_command_for example
95
95
  example_description = example.metadata[:pact_interaction_example_description]
96
- if ENV['PACT_INTERACTION_RERUN_COMMAND']
96
+
97
+ _id = example.metadata[:pact_interaction]._id
98
+ index = example.metadata[:pact_interaction].index
99
+ provider_state = example.metadata[:pact_interaction].provider_state
100
+ description = example.metadata[:pact_interaction].description
101
+ pactfile_uri = example.metadata[:pactfile_uri]
102
+
103
+ if _id && ENV['PACT_INTERACTION_RERUN_COMMAND_FOR_BROKER']
104
+ cmd = String.new(ENV['PACT_INTERACTION_RERUN_COMMAND_FOR_BROKER'])
105
+ cmd.gsub!("<PACT_URI>", example.metadata[:pactfile_uri].to_s)
106
+ cmd.gsub!("<PACT_BROKER_INTERACTION_ID>", "#{_id}")
107
+ colorizer.wrap("#{cmd} ", ::RSpec.configuration.failure_color) + colorizer.wrap("# #{example_description}", ::RSpec.configuration.detail_color)
108
+ elsif ENV['PACT_INTERACTION_RERUN_COMMAND']
97
109
  cmd = String.new(ENV['PACT_INTERACTION_RERUN_COMMAND'])
98
- provider_state = example.metadata[:pact_interaction].provider_state
99
- description = example.metadata[:pact_interaction].description
100
- pactfile_uri = example.metadata[:pactfile_uri]
101
110
  cmd.gsub!("<PACT_URI>", pactfile_uri.to_s)
102
111
  cmd.gsub!("<PACT_DESCRIPTION>", description)
103
112
  cmd.gsub!("<PACT_PROVIDER_STATE>", "#{provider_state}")
113
+ cmd.gsub!("<PACT_INTERACTION_INDEX>", "#{index}")
104
114
  colorizer.wrap("#{cmd} ", ::RSpec.configuration.failure_color) + colorizer.wrap("# #{example_description}", ::RSpec.configuration.detail_color)
105
115
  else
106
- colorizer.wrap("* #{example_description}", ::RSpec.configuration.failure_color)
116
+ message = if _id
117
+ "* #{example_description} (to re-run just this interaction, set environment variable PACT_BROKER_INTERACTION_ID=\"#{_id}\")"
118
+ else
119
+ "* #{example_description} (to re-run just this interaction, set environment variables PACT_DESCRIPTION=\"#{description}\" PACT_PROVIDER_STATE=\"#{provider_state}\")"
120
+ end
121
+ colorizer.wrap(message, ::RSpec.configuration.failure_color)
107
122
  end
108
123
  end
109
124
 
@@ -7,6 +7,7 @@ module Pact
7
7
  module TaskHelper
8
8
 
9
9
  PACT_INTERACTION_RERUN_COMMAND = "bundle exec rake pact:verify:at[<PACT_URI>] PACT_DESCRIPTION=\"<PACT_DESCRIPTION>\" PACT_PROVIDER_STATE=\"<PACT_PROVIDER_STATE>\""
10
+ PACT_INTERACTION_RERUN_COMMAND_FOR_BROKER = "bundle exec rake pact:verify:at[<PACT_URI>] PACT_BROKER_INTERACTION_ID=\"<PACT_BROKER_INTERACTION_ID>\""
10
11
 
11
12
  extend self
12
13
 
@@ -34,6 +35,8 @@ module Pact
34
35
  command_parts << "--backtrace" if ENV['BACKTRACE'] == 'true'
35
36
  command_parts << "--description #{Shellwords.escape(ENV['PACT_DESCRIPTION'])}" if ENV['PACT_DESCRIPTION']
36
37
  command_parts << "--provider-state #{Shellwords.escape(ENV['PACT_PROVIDER_STATE'])}" if ENV['PACT_PROVIDER_STATE']
38
+ command_parts << "--pact-broker-interaction-id #{Shellwords.escape(ENV['PACT_BROKER_INTERACTION_ID'])}" if ENV['PACT_BROKER_INTERACTION_ID']
39
+ command_parts << "--interaction-index #{Shellwords.escape(ENV['PACT_INTERACTION_INDEX'])}" if ENV['PACT_INTERACTION_INDEX']
37
40
  command_parts.flatten.join(" ")
38
41
  end
39
42
 
@@ -41,7 +44,9 @@ module Pact
41
44
  Pact.configuration.output_stream.puts command
42
45
  temporarily_set_env_var 'PACT_EXECUTING_LANGUAGE', 'ruby' do
43
46
  temporarily_set_env_var 'PACT_INTERACTION_RERUN_COMMAND', PACT_INTERACTION_RERUN_COMMAND do
44
- exit_status = system(command) ? 0 : 1
47
+ temporarily_set_env_var 'PACT_INTERACTION_RERUN_COMMAND_FOR_BROKER', PACT_INTERACTION_RERUN_COMMAND_FOR_BROKER do
48
+ exit_status = system(command) ? 0 : 1
49
+ end
45
50
  end
46
51
  end
47
52
  end
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.49.2"
3
+ VERSION = "1.51.1"
4
4
  end
@@ -28,14 +28,14 @@ Gem::Specification.new do |gem|
28
28
 
29
29
  gem.add_runtime_dependency 'rspec', '~> 3.0'
30
30
  gem.add_runtime_dependency 'rack-test', '>= 0.6.3', '< 2.0.0'
31
- gem.add_runtime_dependency 'thor', '~> 0.20'
31
+ gem.add_runtime_dependency 'thor', '>= 0.20', '< 2.0'
32
32
  gem.add_runtime_dependency 'webrick', '~> 1.3'
33
33
  gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
34
34
 
35
35
  gem.add_runtime_dependency 'pact-support', '~> 1.9'
36
36
  gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
37
37
 
38
- gem.add_development_dependency 'rake', '~> 10.0'
38
+ gem.add_development_dependency 'rake', '~> 13.0'
39
39
  gem.add_development_dependency 'webmock', '~> 3.0'
40
40
  gem.add_development_dependency 'fakefs', '0.5' # 0.6.0 blows up
41
41
  gem.add_development_dependency 'hashie', '~> 2.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.49.2
4
+ version: 1.51.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-04-08 00:00:00.000000000 Z
15
+ date: 2020-08-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -52,16 +52,22 @@ dependencies:
52
52
  name: thor
53
53
  requirement: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - "~>"
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0.20'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
58
61
  type: :runtime
59
62
  prerelease: false
60
63
  version_requirements: !ruby/object:Gem::Requirement
61
64
  requirements:
62
- - - "~>"
65
+ - - ">="
63
66
  - !ruby/object:Gem::Version
64
67
  version: '0.20'
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '2.0'
65
71
  - !ruby/object:Gem::Dependency
66
72
  name: webrick
67
73
  requirement: !ruby/object:Gem::Requirement
@@ -130,14 +136,14 @@ dependencies:
130
136
  requirements:
131
137
  - - "~>"
132
138
  - !ruby/object:Gem::Version
133
- version: '10.0'
139
+ version: '13.0'
134
140
  type: :development
135
141
  prerelease: false
136
142
  version_requirements: !ruby/object:Gem::Requirement
137
143
  requirements:
138
144
  - - "~>"
139
145
  - !ruby/object:Gem::Version
140
- version: '10.0'
146
+ version: '13.0'
141
147
  - !ruby/object:Gem::Dependency
142
148
  name: webmock
143
149
  requirement: !ruby/object:Gem::Requirement
@@ -319,6 +325,7 @@ files:
319
325
  - lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
320
326
  - lib/pact/pact_broker/fetch_pacts.rb
321
327
  - lib/pact/pact_broker/notices.rb
328
+ - lib/pact/pact_broker/pact_selection_description.rb
322
329
  - lib/pact/project_root.rb
323
330
  - lib/pact/provider.rb
324
331
  - lib/pact/provider/configuration.rb
@@ -396,8 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
396
403
  - !ruby/object:Gem::Version
397
404
  version: '0'
398
405
  requirements: []
399
- rubyforge_project:
400
- rubygems_version: 2.7.7
406
+ rubygems_version: 3.1.4
401
407
  signing_key:
402
408
  specification_version: 4
403
409
  summary: Enables consumer driven contract testing, providing a mock service and DSL