pact 1.55.1 → 1.55.6

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: 45d7bf4200800cfb20da16b3ef95edc19597badec66d4a4fd716e4229a8a2923
4
- data.tar.gz: cdca3dd4e2401c5f5d0a8994c2dc3cecf47317e6ba0714acac8cc7cab819d9b7
3
+ metadata.gz: 660823c1fa86c41c93fa53306d7e3859753fe79617025d77f82994e52af023f2
4
+ data.tar.gz: 21fc55074a90dac1789809dcc3eff0bdda4525f631bc589a521f5ec4c79617b4
5
5
  SHA512:
6
- metadata.gz: e3d19e95dd00a6252a0e45611b36b8a53c360eb99d5611f0a116de45362a675ba3ed0752619bda3b09b91a1fa0c27a9cf10f714aced846c29ef6c1138fbbb097
7
- data.tar.gz: 5e4d07194b139e690e2fe87d70e23141621b4f438295aa6fff2d0f132d1d8ffe9ab148691bc998b7bbf486067d0885082de538cc6ec06876f77f1476f5730bd4
6
+ metadata.gz: ce0d82537eab4151f1ee7b1673ea1f420e2a6958ee9eb5703984c709bd0581527f1bade40f606e2df60e2500d3d502817bdbce0a1c96401d64ac26362bff2327
7
+ data.tar.gz: 29ef62f2be4fe2320f7ac398a1e1d256182c49d46a020c386b6c6e46089351a6864a9ee65cf3c3307b0f9faad7093ea03945fe67f2ae077313daa2e2d45213f5
@@ -1,3 +1,40 @@
1
+ <a name="v1.55.6"></a>
2
+ ### v1.55.6 (2020-11-06)
3
+
4
+ #### Bug Fixes
5
+
6
+ * require rspec now that pact-support does not depend on it ([5b5c27c](/../../commit/5b5c27c))
7
+
8
+ <a name="v1.55.5"></a>
9
+ ### v1.55.5 (2020-10-12)
10
+
11
+ #### Bug Fixes
12
+
13
+ * **security**
14
+ * hide personal access token given in uri (#225) ([f6db12d](/../../commit/f6db12d))
15
+
16
+ <a name="v1.55.4"></a>
17
+ ### v1.55.4 (2020-10-09)
18
+
19
+ #### Bug Fixes
20
+
21
+ * add back missing output describing the interactions filter ([1a2d7c1](/../../commit/1a2d7c1))
22
+
23
+ <a name="v1.55.3"></a>
24
+ ### v1.55.3 (2020-09-28)
25
+
26
+ #### Bug Fixes
27
+
28
+ * correct logic for determining if all interactions for a pact have been verified ([c4f968e](/../../commit/c4f968e))
29
+ * de-duplicate re-run commands ([0813498](/../../commit/0813498))
30
+
31
+ <a name="v1.55.2"></a>
32
+ ### v1.55.2 (2020-09-26)
33
+
34
+ #### Bug Fixes
35
+
36
+ * correctly calculate exit code when a mix of pending and non pending pacts are verified ([533faa1](/../../commit/533faa1))
37
+
1
38
  <a name="v1.55.1"></a>
2
39
  ### v1.55.1 (2020-09-26)
3
40
 
@@ -27,6 +27,7 @@ module Pact
27
27
  # With RSpec3, if the pact_helper loads a library that adds its own formatter before we set one,
28
28
  # we will get a ProgressFormatter too, and get little dots sprinkled throughout our output.
29
29
  # Load a NilFormatter here to prevent that.
30
+ require 'rspec'
30
31
  require 'pact/rspec'
31
32
  ::RSpec.configuration.add_formatter Pact::RSpec.formatter_class.const_get('NilFormatter')
32
33
  end
@@ -1,6 +1,7 @@
1
1
  require 'pact/consumer_contract/pact_file'
2
2
  require 'pact/hal/http_client'
3
3
  require 'pact/hal/entity'
4
+ require 'pact/consumer_contract'
4
5
 
5
6
  module Pact
6
7
  module Provider
@@ -20,6 +21,14 @@ module Pact
20
21
  @pact_hash ||= JSON.load(pact_json, nil, { max_nesting: 50 })
21
22
  end
22
23
 
24
+ def pending?
25
+ uri.metadata[:pending]
26
+ end
27
+
28
+ def consumer_contract
29
+ @consumer_contract ||= Pact::ConsumerContract.from_json(pact_json)
30
+ end
31
+
23
32
  def hal_entity
24
33
  http_client_keys = [:username, :password, :token]
25
34
  http_client_options = uri.options.reject{ |k, _| !http_client_keys.include?(k) }
@@ -11,6 +11,7 @@ require 'pact/provider/verification_results/publish_all'
11
11
  require 'pact/provider/rspec/pact_broker_formatter'
12
12
  require 'pact/provider/rspec/json_formatter'
13
13
  require 'pact/provider/rspec'
14
+ require 'pact/provider/rspec/calculate_exit_code'
14
15
 
15
16
  module Pact
16
17
  module Provider
@@ -79,6 +80,7 @@ module Pact
79
80
  executing_with_ruby = executing_with_ruby?
80
81
 
81
82
  config.after(:suite) do | suite |
83
+ Pact.provider_world.failed_examples = suite.reporter.failed_examples
82
84
  Pact::Provider::Help::Write.call(Pact.provider_world.pact_sources) if executing_with_ruby
83
85
  end
84
86
  end
@@ -90,7 +92,12 @@ module Pact
90
92
  ::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
91
93
  .run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
92
94
  end
93
- pending_mode? ? 0 : exit_code
95
+
96
+ if options[:ignore_failures]
97
+ 0
98
+ else
99
+ Pact::Provider::RSpec::CalculateExitCode.call(pact_sources, Pact.provider_world.failed_examples)
100
+ end
94
101
  end
95
102
 
96
103
  def rspec_runner_options
@@ -147,8 +154,6 @@ module Pact
147
154
  end
148
155
 
149
156
  ::RSpec.configuration.full_backtrace = @options[:full_backtrace]
150
-
151
- ::RSpec.configuration.failure_color = :yellow if pending_mode?
152
157
  end
153
158
 
154
159
  def ordered_pact_json(pact_json)
@@ -159,20 +164,12 @@ module Pact
159
164
  consumer_contract.to_json
160
165
  end
161
166
 
162
- def all_pacts_pending?
163
- pact_urls.all?{ | pact_url| pact_url.metadata[:pending] }
164
- end
165
-
166
167
  def class_exists? name
167
168
  Kernel.const_get name
168
169
  rescue NameError
169
170
  false
170
171
  end
171
172
 
172
- def pending_mode?
173
- (all_pacts_pending? || options[:ignore_failures])
174
- end
175
-
176
173
  def executing_with_ruby?
177
174
  ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
178
175
  end
@@ -17,7 +17,7 @@ module Pact
17
17
  end
18
18
 
19
19
  def basic_auth?
20
- !!username
20
+ !!username && !!password
21
21
  end
22
22
 
23
23
  def username
@@ -29,12 +29,23 @@ module Pact
29
29
  end
30
30
 
31
31
  def to_s
32
- if basic_auth? && uri.start_with?('http://', 'https://')
32
+ if basic_auth? && http_or_https_uri?
33
33
  URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
34
+ elsif personal_access_token? && http_or_https_uri?
35
+ URI(@uri).tap { |x| x.userinfo="*****"}.to_s
34
36
  else
35
37
  uri
36
38
  end
37
39
  end
40
+
41
+ private def personal_access_token?
42
+ !!username && !password
43
+ end
44
+
45
+ private def http_or_https_uri?
46
+ uri.start_with?('http://', 'https://')
47
+ end
48
+
38
49
  end
39
50
  end
40
51
  end
@@ -26,8 +26,10 @@ module Pact
26
26
  Pact.configuration.output_stream.puts "INFO: Reading pact at #{pact_uri}"
27
27
  consumer_contract = Pact::ConsumerContract.from_json(pact_json)
28
28
  suffix = pact_uri.metadata[:pending] ? " [PENDING]": ""
29
+ example_group_description = "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}"
30
+ example_group_metadata = { pactfile_uri: pact_uri, pact_criteria: options[:criteria] }
29
31
 
30
- ::RSpec.describe "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}", pactfile_uri: pact_uri do
32
+ ::RSpec.describe example_group_description, example_group_metadata do
31
33
  honour_consumer_contract consumer_contract, options.merge(
32
34
  pact_json: pact_json,
33
35
  pact_uri: pact_uri,
@@ -89,9 +91,8 @@ module Pact
89
91
  pact_interaction_example_description: interaction_description_for_rerun_command(interaction),
90
92
  pact_uri: options[:pact_uri],
91
93
  pact_source: options[:pact_source],
92
- pact_ignore_failures: options[:pact_uri].metadata[:pending] || options[:ignore_failures],
93
- pact_consumer_contract: options[:consumer_contract],
94
- pact_criteria: options[:criteria]
94
+ pact_ignore_failures: options[:pact_source].pending? || options[:ignore_failures],
95
+ pact_consumer_contract: options[:consumer_contract]
95
96
  }
96
97
 
97
98
  describe description_for(interaction), metadata do
@@ -0,0 +1,18 @@
1
+ module Pact
2
+ module Provider
3
+ module RSpec
4
+ module CalculateExitCode
5
+ def self.call(pact_sources, failed_examples)
6
+ any_non_pending_failures = pact_sources.any? do |pact_source|
7
+ if pact_source.pending?
8
+ nil
9
+ else
10
+ failed_examples.select { |e| e.metadata[:pact_source] == pact_source }.any?
11
+ end
12
+ end
13
+ any_non_pending_failures ? 1 : 0
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -25,6 +25,7 @@ module Pact
25
25
  C = ::Term::ANSIColor
26
26
 
27
27
  def example_group_started(notification)
28
+ # This is the metadata on the top level "Verifying a pact between X and Y" describe block
28
29
  if @group_level == 0
29
30
  Pact.configuration.output_stream.puts
30
31
  pact_uri = notification.group.metadata[:pactfile_uri]
@@ -65,10 +66,6 @@ module Pact
65
66
  pending_interaction_examples(summary).size
66
67
  end
67
68
 
68
- def ignore_failures?(summary)
69
- summary.failed_examples.any?{ |e| e.metadata[:pact_ignore_failures] }
70
- end
71
-
72
69
  def failure_title summary
73
70
  ::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure")
74
71
  end
@@ -96,12 +93,14 @@ module Pact
96
93
  interaction_rerun_commands(pending_interaction_examples(summary)).each do | message |
97
94
  output.puts(message)
98
95
  end
96
+ set_rspec_failure_color(:red)
99
97
  end
100
98
 
101
- set_rspec_failure_color(:red)
102
- output.puts("\nFailed interactions:\n\n")
103
- interaction_rerun_commands(failed_interaction_examples(summary)).each do | message |
104
- output.puts(message)
99
+ if failed_interactions_count(summary) > 0
100
+ output.puts("\nFailed interactions:\n\n")
101
+ interaction_rerun_commands(failed_interaction_examples(summary)).each do | message |
102
+ output.puts(message)
103
+ end
105
104
  end
106
105
  end
107
106
 
@@ -130,7 +129,7 @@ module Pact
130
129
  def interaction_rerun_commands examples
131
130
  examples.collect do |example|
132
131
  interaction_rerun_command_for example
133
- end.compact
132
+ end.compact.uniq
134
133
  end
135
134
 
136
135
  def interaction_unique_key(example)
@@ -8,7 +8,7 @@ module Pact
8
8
  module RSpec
9
9
  module Matchers
10
10
  module RSpec2Delegator
11
- # For backwards compatiblity with rspec-2
11
+ # For backwards compatibility with rspec-2
12
12
  def method_missing(method, *args, &block)
13
13
  if method_name == :failure_message_for_should
14
14
  failure_message method, *args, &block
@@ -28,7 +28,23 @@ module Pact
28
28
  end
29
29
 
30
30
  def publishable?
31
- executed_interactions_count == all_interactions_count && all_interactions_count > 0
31
+ if defined?(@publishable)
32
+ @publishable
33
+ else
34
+ @publishable = pact_source.consumer_contract.interactions.all? do | interaction |
35
+ examples_for_pact_uri.any?{ |e| example_is_for_interaction?(e, interaction) }
36
+ end && examples_for_pact_uri.count > 0
37
+ end
38
+ end
39
+
40
+ def example_is_for_interaction?(example, interaction)
41
+ # Use the Pact Broker id if supported
42
+ if interaction._id
43
+ example[:pact_interaction]._id == interaction._id
44
+ else
45
+ # fall back to object equality (based on the field values of the interaction)
46
+ example[:pact_interaction] == interaction
47
+ end
32
48
  end
33
49
 
34
50
  def examples_for_pact_uri
@@ -39,18 +55,6 @@ module Pact
39
55
  examples_for_pact_uri.count{ |e| e[:status] != 'passed' }
40
56
  end
41
57
 
42
- def executed_interactions_count
43
- examples_for_pact_uri
44
- .collect { |e| e[:pact_interaction].object_id }
45
- .uniq
46
- .count
47
- end
48
-
49
- def all_interactions_count
50
- interactions = (pact_source.pact_hash['interactions'] || pact_source.pact_hash['messages'])
51
- interactions ? interactions.count : 0
52
- end
53
-
54
58
  def test_results_hash_for_pact_uri
55
59
  {
56
60
  tests: examples_for_pact_uri.collect{ |e| clean_example(e) },
@@ -81,7 +81,7 @@ module Pact
81
81
  Pact.configuration.output_stream.puts "INFO: Tagging version #{provider_application_version} of #{provider_name} as #{tag.inspect}"
82
82
  tag_entity = tag_link.expand(version: provider_application_version, tag: tag).put
83
83
  unless tag_entity.success?
84
- raise PublicationError.new("Error returned from tagging request #{tag_entity.response.code} #{tag_entity.response.body}")
84
+ raise PublicationError.new("Error returned from tagging request: status=#{tag_entity.response.code} body=#{tag_entity.response.body}")
85
85
  end
86
86
  end
87
87
  end
@@ -14,7 +14,7 @@ module Pact
14
14
  module Provider
15
15
  class World
16
16
 
17
- attr_accessor :pact_sources
17
+ attr_accessor :pact_sources, :failed_examples
18
18
 
19
19
  def provider_states
20
20
  @provider_states_proxy ||= Pact::Provider::State::ProviderStateProxy.new
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.55.1"
3
+ VERSION = "1.55.6"
4
4
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |gem|
32
32
  gem.add_runtime_dependency 'webrick', '~> 1.3'
33
33
  gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
34
34
 
35
- gem.add_runtime_dependency 'pact-support', '~> 1.9'
35
+ gem.add_runtime_dependency 'pact-support', '~> 1.15'
36
36
  gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
37
37
 
38
38
  gem.add_development_dependency 'rake', '~> 13.0'
@@ -43,6 +43,6 @@ Gem::Specification.new do |gem|
43
43
  gem.add_development_dependency 'faraday', '~> 0.13'
44
44
  gem.add_development_dependency 'conventional-changelog', '~> 1.3'
45
45
  gem.add_development_dependency 'bump', '~> 0.5'
46
- gem.add_development_dependency 'pact-message', '~> 0.6'
46
+ gem.add_development_dependency 'pact-message', '~> 0.8'
47
47
  gem.add_development_dependency 'rspec-its', '~> 1.3'
48
48
  end
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.55.1
4
+ version: 1.55.6
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-09-26 00:00:00.000000000 Z
15
+ date: 2020-11-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '1.9'
105
+ version: '1.15'
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '1.9'
112
+ version: '1.15'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: pact-mock_service
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -248,14 +248,14 @@ dependencies:
248
248
  requirements:
249
249
  - - "~>"
250
250
  - !ruby/object:Gem::Version
251
- version: '0.6'
251
+ version: '0.8'
252
252
  type: :development
253
253
  prerelease: false
254
254
  version_requirements: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - "~>"
257
257
  - !ruby/object:Gem::Version
258
- version: '0.6'
258
+ version: '0.8'
259
259
  - !ruby/object:Gem::Dependency
260
260
  name: rspec-its
261
261
  requirement: !ruby/object:Gem::Requirement
@@ -352,6 +352,7 @@ files:
352
352
  - lib/pact/provider/request.rb
353
353
  - lib/pact/provider/rspec.rb
354
354
  - lib/pact/provider/rspec/backtrace_formatter.rb
355
+ - lib/pact/provider/rspec/calculate_exit_code.rb
355
356
  - lib/pact/provider/rspec/custom_options_file
356
357
  - lib/pact/provider/rspec/formatter_rspec_2.rb
357
358
  - lib/pact/provider/rspec/formatter_rspec_3.rb