pact 1.46.1 → 1.47.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb +8 -5
- data/lib/pact/pact_broker/notices.rb +34 -0
- data/lib/pact/provider/pact_source.rb +1 -1
- data/lib/pact/provider/pact_spec_runner.rb +1 -1
- data/lib/pact/provider/rspec.rb +11 -5
- data/lib/pact/provider/rspec/json_formatter.rb +18 -6
- data/lib/pact/provider/verification_results/publish.rb +3 -0
- data/lib/pact/provider/verification_results/publish_all.rb +14 -1
- data/lib/pact/provider/verification_results/verification_result.rb +1 -4
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baf86f2efd8ed6641172f514a29fc1493e79cfb291c516a8c4059d94f778d58e
|
4
|
+
data.tar.gz: 264598f33c4561cd0ce013a8371d27fbb05855c392d762827a002dd0ab4240de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e12522bd3471bb2268ab523a50d7198f8ce8c60ea78031e2f01533628d8c16b11352ceb52e17b879f5306b9b5ce3ab06ef4af9ee1fa2b8abf13a4a74847732de
|
7
|
+
data.tar.gz: f8d1e0d854deebf0451c65419e142a48ff1e8ded5cf2a0404ef06929520b77a68e20000c06209aac607fa58d3cbb86af4fb252fe2cf334ee4202aad4919578a8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
<a name="v1.47.0"></a>
|
2
|
+
### v1.47.0 (2020-02-08)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* update json formatter output ([376e47a](/../../commit/376e47a))
|
8
|
+
* add pact metadata to json formatter ([6c6ddb8](/../../commit/6c6ddb8))
|
9
|
+
|
10
|
+
|
1
11
|
<a name="v1.46.1"></a>
|
2
12
|
### v1.46.1 (2020-01-22)
|
3
13
|
|
@@ -3,6 +3,7 @@ require 'pact/hal/http_client'
|
|
3
3
|
require 'pact/provider/pact_uri'
|
4
4
|
require 'pact/errors'
|
5
5
|
require 'pact/pact_broker/fetch_pacts'
|
6
|
+
require 'pact/pact_broker/notices'
|
6
7
|
|
7
8
|
module Pact
|
8
9
|
module PactBroker
|
@@ -51,7 +52,8 @@ module Pact
|
|
51
52
|
pacts_for_verification_entity.response.body[EMBEDDED][PACTS].collect do | pact |
|
52
53
|
metadata = {
|
53
54
|
pending: pact["verificationProperties"]["pending"],
|
54
|
-
notices: extract_notices(pact)
|
55
|
+
notices: extract_notices(pact),
|
56
|
+
short_description: pact["shortDescription"]
|
55
57
|
}
|
56
58
|
Pact::Provider::PactURI.new(pact[LINKS][SELF][HREF], http_client_options, metadata)
|
57
59
|
end
|
@@ -69,11 +71,12 @@ module Pact
|
|
69
71
|
q["includePendingStatus"] = true if options[:include_pending_status]
|
70
72
|
q["consumerVersionSelectors"] = consumer_version_selectors if consumer_version_selectors.any?
|
71
73
|
q["providerVersionTags"] = provider_version_tags if provider_version_tags.any?
|
74
|
+
q["includeWipPactsSince"] = options[:include_wip_pacts_since] if options[:include_wip_pacts_since]
|
72
75
|
q
|
73
76
|
end
|
74
77
|
|
75
78
|
def extract_notices(pact)
|
76
|
-
(pact["verificationProperties"]["notices"] || []).collect{ |notice| symbolize_keys(notice) }
|
79
|
+
Notices.new((pact["verificationProperties"]["notices"] || []).collect{ |notice| symbolize_keys(notice) })
|
77
80
|
end
|
78
81
|
|
79
82
|
def symbolize_keys(hash)
|
@@ -82,15 +85,15 @@ module Pact
|
|
82
85
|
|
83
86
|
def log_message
|
84
87
|
latest = consumer_version_selectors.any? ? "" : "latest "
|
85
|
-
message = "INFO: Fetching
|
88
|
+
message = "INFO: Fetching pacts for #{provider} from #{broker_base_url} with the selection criteria: "
|
86
89
|
if consumer_version_selectors.any?
|
87
90
|
desc = consumer_version_selectors.collect do |selector|
|
88
|
-
all_or_latest = selector[:all] ? "all" : "latest"
|
91
|
+
all_or_latest = selector[:all] ? "all for tag" : "latest for tag"
|
89
92
|
# TODO support fallback
|
90
93
|
name = selector[:fallback] ? "#{selector[:tag]} (or #{selector[:fallback]} if not found)" : selector[:tag]
|
91
94
|
"#{all_or_latest} #{name}"
|
92
95
|
end.join(", ")
|
93
|
-
message << "
|
96
|
+
message << ": #{desc}"
|
94
97
|
end
|
95
98
|
Pact.configuration.output_stream.puts message
|
96
99
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pact
|
2
|
+
module PactBroker
|
3
|
+
class Notices < Array
|
4
|
+
def before_verification_notices
|
5
|
+
select { | notice | notice[:when].nil? || notice[:when].start_with?('before_verification') }
|
6
|
+
end
|
7
|
+
|
8
|
+
def before_verification_notices_text
|
9
|
+
before_verification_notices.collect{ | notice | notice[:text] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def after_verification_notices(success, published)
|
13
|
+
select { | notice | notice[:when] == "after_verification:success_#{success}_published_#{published}" || notice[:when] == "after_verification" }
|
14
|
+
.collect do | notice |
|
15
|
+
notice.merge(:when => simplify_notice_when(notice[:when]))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_verification_notices_text(success, published)
|
20
|
+
after_verification_notices(success, published).collect{ | notice | notice[:text] }
|
21
|
+
end
|
22
|
+
|
23
|
+
def all_notices(success, published)
|
24
|
+
before_verification_notices + after_verification_notices(success, published)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def simplify_notice_when(when_key)
|
30
|
+
when_key.split(":").first
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -122,7 +122,7 @@ module Pact
|
|
122
122
|
ignore_failures: options[:ignore_failures],
|
123
123
|
request_customizer: options[:request_customizer]
|
124
124
|
}
|
125
|
-
honour_pactfile pact_source
|
125
|
+
honour_pactfile pact_source, ordered_pact_json(pact_source.pact_json), spec_options
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
data/lib/pact/provider/rspec.rb
CHANGED
@@ -21,16 +21,20 @@ module Pact
|
|
21
21
|
|
22
22
|
include ::RSpec::Core::DSL
|
23
23
|
|
24
|
-
def honour_pactfile
|
24
|
+
def honour_pactfile pact_source, pact_json, options
|
25
|
+
pact_uri = pact_source.uri
|
25
26
|
Pact.configuration.output_stream.puts "INFO: Reading pact at #{pact_uri}"
|
26
|
-
|
27
|
-
|
27
|
+
if pact_uri.metadata[:notices]
|
28
|
+
pact_uri.metadata[:notices].before_verification_notices_text.each do | text |
|
29
|
+
Pact.configuration.output_stream.puts("DEBUG: #{text}")
|
30
|
+
end
|
28
31
|
end
|
32
|
+
|
29
33
|
Pact.configuration.output_stream.puts "DEBUG: Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
|
30
34
|
consumer_contract = Pact::ConsumerContract.from_json(pact_json)
|
31
35
|
suffix = pact_uri.metadata[:pending] ? " [PENDING]": ""
|
32
36
|
::RSpec.describe "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}", pactfile_uri: pact_uri do
|
33
|
-
honour_consumer_contract consumer_contract, options.merge(pact_json: pact_json, pact_uri: pact_uri)
|
37
|
+
honour_consumer_contract consumer_contract, options.merge(pact_json: pact_json, pact_uri: pact_uri, pact_source: pact_source, consumer_contract: consumer_contract)
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
@@ -78,7 +82,9 @@ module Pact
|
|
78
82
|
pact_interaction: interaction,
|
79
83
|
pact_interaction_example_description: interaction_description_for_rerun_command(interaction),
|
80
84
|
pact_uri: options[:pact_uri],
|
81
|
-
|
85
|
+
pact_source: options[:pact_source],
|
86
|
+
pact_ignore_failures: options[:pact_uri].metadata[:pending] || options[:ignore_failures],
|
87
|
+
pact_consumer_contract: options[:consumer_contract]
|
82
88
|
}
|
83
89
|
|
84
90
|
describe description_for(interaction), metadata do
|
@@ -8,19 +8,21 @@ module Pact
|
|
8
8
|
|
9
9
|
def dump_summary(summary)
|
10
10
|
super(create_custom_summary(summary))
|
11
|
-
output_hash[:summary][:
|
11
|
+
output_hash[:summary][:pacts] = pacts(summary)
|
12
12
|
end
|
13
13
|
|
14
14
|
def format_example(example)
|
15
15
|
{
|
16
16
|
:id => example.id,
|
17
|
+
:interaction_index => example.metadata[:pact_interaction].index,
|
17
18
|
:description => example.description,
|
18
19
|
:full_description => example.full_description,
|
19
20
|
:status => calculate_status(example),
|
20
21
|
:file_path => example.metadata[:file_path],
|
21
22
|
:line_number => example.metadata[:line_number],
|
22
23
|
:run_time => example.execution_result.run_time,
|
23
|
-
:mismatches => extract_differences(example)
|
24
|
+
:mismatches => extract_differences(example),
|
25
|
+
:pact_url => example.metadata[:pact_uri].uri
|
24
26
|
}
|
25
27
|
end
|
26
28
|
|
@@ -54,12 +56,22 @@ module Pact
|
|
54
56
|
# If the JSON formatter is used by someone else and they have multiple pacts, all the notices
|
55
57
|
# for the pacts will be mushed together in one collection, so it will be hard to know which notice
|
56
58
|
# belongs to which pact.
|
57
|
-
def
|
58
|
-
|
59
|
+
def pacts(summary)
|
60
|
+
unique_pact_metadatas(summary).collect do | example_metadata |
|
61
|
+
pact_uri = example_metadata[:pact_uri]
|
62
|
+
notices = (pact_uri.metadata[:notices] && pact_uri.metadata[:notices].before_verification_notices) || []
|
63
|
+
{
|
64
|
+
notices: notices,
|
65
|
+
url: pact_uri.uri,
|
66
|
+
consumer_name: example_metadata[:pact_consumer_contract].consumer.name,
|
67
|
+
provider_name: example_metadata[:pact_consumer_contract].provider.name,
|
68
|
+
short_description: pact_uri.metadata[:short_description]
|
69
|
+
}
|
70
|
+
end
|
59
71
|
end
|
60
72
|
|
61
|
-
def
|
62
|
-
summary.examples.collect(&:metadata).
|
73
|
+
def unique_pact_metadatas(summary)
|
74
|
+
summary.examples.collect(&:metadata).group_by{ | metadata | metadata[:pact_uri].uri }.values.collect(&:first)
|
63
75
|
end
|
64
76
|
|
65
77
|
def create_custom_summary(summary)
|
@@ -17,7 +17,12 @@ module Pact
|
|
17
17
|
|
18
18
|
def call
|
19
19
|
verification_results.collect do | (pact_source, verification_result) |
|
20
|
-
|
20
|
+
published = false
|
21
|
+
begin
|
22
|
+
published = Publish.call(pact_source, verification_result)
|
23
|
+
ensure
|
24
|
+
print_after_verification_notices(pact_source, verification_result, published)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
@@ -29,6 +34,14 @@ module Pact
|
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
37
|
+
def print_after_verification_notices(pact_source, verification_result, published)
|
38
|
+
if pact_source.uri.metadata[:notices]
|
39
|
+
pact_source.uri.metadata[:notices].after_verification_notices_text(verification_result.success, published).each do | text |
|
40
|
+
Pact.configuration.output_stream.puts "DEBUG: #{text}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
attr_reader :pact_sources, :test_results_hash
|
33
46
|
end
|
34
47
|
end
|
@@ -4,6 +4,7 @@ module Pact
|
|
4
4
|
module Provider
|
5
5
|
module VerificationResults
|
6
6
|
class VerificationResult
|
7
|
+
attr_reader :success, :provider_application_version, :test_results_hash
|
7
8
|
|
8
9
|
def initialize publishable, success, provider_application_version, test_results_hash
|
9
10
|
@publishable = publishable
|
@@ -31,10 +32,6 @@ module Pact
|
|
31
32
|
def to_s
|
32
33
|
"[success: #{success}, providerApplicationVersion: #{provider_application_version}]"
|
33
34
|
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
attr_reader :success, :provider_application_version, :test_results_hash
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
@@ -44,4 +44,5 @@ Gem::Specification.new do |gem|
|
|
44
44
|
gem.add_development_dependency 'conventional-changelog', '~> 1.3'
|
45
45
|
gem.add_development_dependency 'bump', '~> 0.5'
|
46
46
|
gem.add_development_dependency 'pact-message', '~> 0.6'
|
47
|
+
gem.add_development_dependency 'rspec-its', '~> 1.3'
|
47
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.
|
4
|
+
version: 1.47.0
|
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-
|
15
|
+
date: 2020-02-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|
@@ -250,6 +250,20 @@ dependencies:
|
|
250
250
|
- - "~>"
|
251
251
|
- !ruby/object:Gem::Version
|
252
252
|
version: '0.6'
|
253
|
+
- !ruby/object:Gem::Dependency
|
254
|
+
name: rspec-its
|
255
|
+
requirement: !ruby/object:Gem::Requirement
|
256
|
+
requirements:
|
257
|
+
- - "~>"
|
258
|
+
- !ruby/object:Gem::Version
|
259
|
+
version: '1.3'
|
260
|
+
type: :development
|
261
|
+
prerelease: false
|
262
|
+
version_requirements: !ruby/object:Gem::Requirement
|
263
|
+
requirements:
|
264
|
+
- - "~>"
|
265
|
+
- !ruby/object:Gem::Version
|
266
|
+
version: '1.3'
|
253
267
|
description: Enables consumer driven contract testing, providing a mock service and
|
254
268
|
DSL for the consumer project, and interaction playback and verification for the
|
255
269
|
service provider project.
|
@@ -304,6 +318,7 @@ files:
|
|
304
318
|
- lib/pact/pact_broker.rb
|
305
319
|
- lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
|
306
320
|
- lib/pact/pact_broker/fetch_pacts.rb
|
321
|
+
- lib/pact/pact_broker/notices.rb
|
307
322
|
- lib/pact/project_root.rb
|
308
323
|
- lib/pact/provider.rb
|
309
324
|
- lib/pact/provider/configuration.rb
|