pact 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/lib/pact/cli/run_pact_verification.rb +2 -1
- data/lib/pact/cli.rb +1 -1
- data/lib/pact/consumer/configuration/mock_service.rb +1 -1
- data/lib/pact/hal/entity.rb +10 -2
- data/lib/pact/hal/http_client.rb +11 -4
- data/lib/pact/hal/link.rb +1 -1
- data/lib/pact/pact_broker/fetch_pacts.rb +60 -47
- data/lib/pact/pact_broker/fetch_wip_pacts.rb +56 -0
- data/lib/pact/pact_broker.rb +19 -0
- data/lib/pact/provider/configuration/pact_verification_from_broker.rb +57 -0
- data/lib/pact/provider/configuration/service_provider_dsl.rb +9 -0
- data/lib/pact/provider/pact_spec_runner.rb +6 -2
- data/lib/pact/provider/pact_verification.rb +14 -14
- data/lib/pact/provider/rspec/formatter_rspec_3.rb +18 -2
- data/lib/pact/provider/rspec.rb +5 -3
- data/lib/pact/provider/world.rb +16 -2
- data/lib/pact/retry.rb +2 -0
- data/lib/pact/tasks/task_helper.rb +4 -3
- data/lib/pact/tasks/verification_task.rb +3 -1
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +1 -1
- metadata +5 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4544628feb78e41d434d8df2fa467c3795b0849
|
|
4
|
+
data.tar.gz: 22c2d7a7caa71c7da7dd33e232a44ba5374f3fd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1e6ddfcaad18582eb50938d8599e02d19a68efc4053f26e677ccd44125d3c855d4447a13e11a900652612ba1eec1d13759d18fbf32824f8d4c686d06601f9fc
|
|
7
|
+
data.tar.gz: 572c7b4c21f1143d3352620f4596f923917dc974c590b78a2cc9cd2fed071d9d5a5cf2ffe41e369e9cfda4ae6201713760ff3e263a6a74a34ccec747b5b3bcd4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
<a name="v1.29.0"></a>
|
|
2
|
+
### v1.29.0 (2018-07-24)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* return plain string URLs from Pact::PactBroker.fetch_pact_uris ([1aa1989](/../../commit/1aa1989))
|
|
8
|
+
* use beta:wip-provider-pacts rather than pb:wip-provider-pacts to fetch WIP pacts ([3bb0501](/../../commit/3bb0501))
|
|
9
|
+
* allow WIP pacts to be verified without causing the process to return an non zero exit code ([9e6de46](/../../commit/9e6de46))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* add missing require ([0aa2d2a](/../../commit/0aa2d2a))
|
|
15
|
+
* default pact specification version to 2 ([917891a](/../../commit/917891a))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<a name="v1.28.0"></a>
|
|
19
|
+
### v1.28.0 (2018-06-24)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#### Features
|
|
23
|
+
|
|
24
|
+
* add logging to indicate which pacts are being fetched from the broker ([06fa615](/../../commit/06fa615))
|
|
25
|
+
* allow verbose http logging to be turned on when fetching pacts URLs from the broker ([436f3f2](/../../commit/436f3f2))
|
|
26
|
+
* allow pacts to be dynamically fetched from a pact broker by provider name and tags ([ef97898](/../../commit/ef97898))
|
|
27
|
+
|
|
28
|
+
#### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* reverting safe navigation operator to chained calls. ([8194ed6](/../../commit/8194ed6))
|
|
31
|
+
|
|
32
|
+
|
|
1
33
|
<a name="v1.27.0"></a>
|
|
2
34
|
### v1.27.0 (2018-06-22)
|
|
3
35
|
|
data/lib/pact/cli.rb
CHANGED
|
@@ -8,6 +8,7 @@ module Pact
|
|
|
8
8
|
desc 'verify', "Verify a pact"
|
|
9
9
|
method_option :pact_helper, aliases: "-h", desc: "Pact helper file", :required => true
|
|
10
10
|
method_option :pact_uri, aliases: "-p", desc: "Pact URI"
|
|
11
|
+
method_option :wip, type: :boolean, default: false, desc: "If WIP, process will always exit with exit code 0", hide: true
|
|
11
12
|
method_option :pact_broker_username, aliases: "-u", desc: "Pact broker user name"
|
|
12
13
|
method_option :pact_broker_password, aliases: "-w", desc: "Pact broker password"
|
|
13
14
|
method_option :backtrace, aliases: "-b", desc: "Show full backtrace", :default => false, :type => :boolean
|
|
@@ -33,6 +34,5 @@ module Pact
|
|
|
33
34
|
require 'pact/doc/generator'
|
|
34
35
|
Pact::Doc::Generate.call(options[:pact_dir], options[:doc_dir], [Pact::Doc::Markdown::Generator])
|
|
35
36
|
end
|
|
36
|
-
|
|
37
37
|
end
|
|
38
38
|
end
|
data/lib/pact/hal/entity.rb
CHANGED
|
@@ -48,8 +48,8 @@ module Pact
|
|
|
48
48
|
@response
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def fetch(key)
|
|
52
|
-
@links[key]
|
|
51
|
+
def fetch(key, fallback_key = nil)
|
|
52
|
+
@links[key] || (fallback_key && @links[fallback_key])
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def method_missing(method_name, *args, &block)
|
|
@@ -68,6 +68,14 @@ module Pact
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
class ErrorEntity < Entity
|
|
71
|
+
|
|
72
|
+
def initialize(data, http_client, response = nil)
|
|
73
|
+
@data = data
|
|
74
|
+
@links = {}
|
|
75
|
+
@client = http_client
|
|
76
|
+
@response = response
|
|
77
|
+
end
|
|
78
|
+
|
|
71
79
|
def success?
|
|
72
80
|
false
|
|
73
81
|
end
|
data/lib/pact/hal/http_client.rb
CHANGED
|
@@ -3,11 +3,12 @@ require 'pact/retry'
|
|
|
3
3
|
module Pact
|
|
4
4
|
module Hal
|
|
5
5
|
class HttpClient
|
|
6
|
-
attr_accessor :username, :password
|
|
6
|
+
attr_accessor :username, :password, :verbose
|
|
7
7
|
|
|
8
8
|
def initialize options
|
|
9
9
|
@username = options[:username]
|
|
10
10
|
@password = options[:password]
|
|
11
|
+
@verbose = options[:verbose]
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def get href, params = {}, headers = {}
|
|
@@ -41,9 +42,11 @@ module Pact
|
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def perform_request request, uri
|
|
44
|
-
options = {:use_ssl => uri.scheme == 'https'}
|
|
45
45
|
response = Retry.until_true do
|
|
46
|
-
Net::HTTP.
|
|
46
|
+
http = Net::HTTP.new(uri.host, uri.port, :ENV)
|
|
47
|
+
http.set_debug_output(Pact.configuration.output_stream) if verbose
|
|
48
|
+
http.use_ssl = (uri.scheme == 'https')
|
|
49
|
+
http.start do |http|
|
|
47
50
|
http.request request
|
|
48
51
|
end
|
|
49
52
|
end
|
|
@@ -52,7 +55,7 @@ module Pact
|
|
|
52
55
|
|
|
53
56
|
class Response < SimpleDelegator
|
|
54
57
|
def body
|
|
55
|
-
bod =
|
|
58
|
+
bod = raw_body
|
|
56
59
|
if bod && bod != ''
|
|
57
60
|
JSON.parse(bod)
|
|
58
61
|
else
|
|
@@ -60,6 +63,10 @@ module Pact
|
|
|
60
63
|
end
|
|
61
64
|
end
|
|
62
65
|
|
|
66
|
+
def raw_body
|
|
67
|
+
__getobj__().body
|
|
68
|
+
end
|
|
69
|
+
|
|
63
70
|
def success?
|
|
64
71
|
__getobj__().code.start_with?("2")
|
|
65
72
|
end
|
data/lib/pact/hal/link.rb
CHANGED
|
@@ -49,7 +49,7 @@ module Pact
|
|
|
49
49
|
if http_response.success?
|
|
50
50
|
Entity.new(http_response.body, @http_client, http_response)
|
|
51
51
|
else
|
|
52
|
-
ErrorEntity.new(http_response.
|
|
52
|
+
ErrorEntity.new(http_response.raw_body, @http_client, http_response)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -1,89 +1,102 @@
|
|
|
1
1
|
require 'pact/hal/entity'
|
|
2
2
|
require 'pact/hal/http_client'
|
|
3
|
+
require 'pact/provider/pact_uri'
|
|
3
4
|
|
|
4
5
|
module Pact
|
|
5
6
|
module PactBroker
|
|
6
7
|
class FetchPacts
|
|
7
|
-
attr_reader :provider, :tags, :broker_base_url, :
|
|
8
|
+
attr_reader :provider, :tags, :broker_base_url, :http_client_options, :http_client, :index_entity
|
|
8
9
|
|
|
9
10
|
ALL_PROVIDER_TAG_RELATION = 'pb:provider-pacts-with-tag'.freeze
|
|
10
11
|
LATEST_PROVIDER_TAG_RELATION = 'pb:latest-provider-pacts-with-tag'.freeze
|
|
11
|
-
ALL_PROVIDER_RELATION = 'pb:provider-pacts'.freeze
|
|
12
12
|
LATEST_PROVIDER_RELATION = 'pb:latest-provider-pacts'.freeze
|
|
13
13
|
PACTS = 'pacts'.freeze
|
|
14
|
+
PB_PACTS = 'pb:pacts'.freeze
|
|
14
15
|
HREF = 'href'.freeze
|
|
15
16
|
|
|
16
|
-
def initialize(provider, tags, broker_base_url,
|
|
17
|
+
def initialize(provider, tags, broker_base_url, http_client_options)
|
|
17
18
|
@provider = provider
|
|
18
|
-
@tags = tags
|
|
19
|
+
@tags = (tags || []).collect do |tag|
|
|
20
|
+
if tag.is_a?(String)
|
|
21
|
+
{ name: tag, all: false, fallback: nil }
|
|
22
|
+
else
|
|
23
|
+
tag
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
@http_client_options = http_client_options
|
|
19
27
|
@broker_base_url = broker_base_url
|
|
20
|
-
@http_client = Pact::Hal::HttpClient.new(
|
|
21
|
-
@all_pacts = all_pacts
|
|
28
|
+
@http_client = Pact::Hal::HttpClient.new(http_client_options)
|
|
22
29
|
end
|
|
23
30
|
|
|
24
|
-
def self.call(provider, tags, broker_base_url,
|
|
25
|
-
new(provider, tags, broker_base_url,
|
|
31
|
+
def self.call(provider, tags, broker_base_url, http_client_options)
|
|
32
|
+
new(provider, tags, broker_base_url, http_client_options).call
|
|
26
33
|
end
|
|
27
34
|
|
|
28
35
|
def call
|
|
29
|
-
|
|
30
|
-
if
|
|
31
|
-
|
|
36
|
+
log_message
|
|
37
|
+
if index.success?
|
|
38
|
+
if any_tags?
|
|
39
|
+
tagged_pacts_for_provider
|
|
40
|
+
else
|
|
41
|
+
latest_pacts_for_provider
|
|
42
|
+
end
|
|
32
43
|
else
|
|
33
|
-
|
|
44
|
+
raise Pact::Error.new("Error retrieving #{broker_base_url} status=#{index_entity.response.code} #{index_entity.response.raw_body}")
|
|
34
45
|
end
|
|
35
46
|
end
|
|
36
47
|
|
|
37
48
|
private
|
|
38
49
|
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
get_all_pacts_for_provider
|
|
42
|
-
else
|
|
43
|
-
get_latest_pacts_for_provider
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def get_tagged_pacts_for_provider
|
|
48
|
-
if all_pacts
|
|
49
|
-
get_all_tagged_pacts_for_provider
|
|
50
|
-
else
|
|
51
|
-
get_latest_tagged_pacts_for_provider
|
|
52
|
-
end
|
|
50
|
+
def any_tags?
|
|
51
|
+
tags && tags.any?
|
|
53
52
|
end
|
|
54
53
|
|
|
55
|
-
def
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
def tagged_pacts_for_provider
|
|
55
|
+
tags.collect do |tag|
|
|
56
|
+
link = link_for(tag)
|
|
57
|
+
urls = pact_urls(link.expand(provider: provider, tag: tag[:name]).get)
|
|
58
|
+
if urls.empty? && tag[:fallback]
|
|
59
|
+
urls = pact_urls(link.expand(provider: provider, tag: tag[:fallback]).get)
|
|
60
|
+
end
|
|
61
|
+
urls
|
|
62
|
+
end.flatten
|
|
58
63
|
end
|
|
59
64
|
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
def link_for(tag)
|
|
66
|
+
if !tag[:all]
|
|
67
|
+
index_entity._link(LATEST_PROVIDER_TAG_RELATION)
|
|
68
|
+
else
|
|
69
|
+
index_entity._link(ALL_PROVIDER_TAG_RELATION)
|
|
70
|
+
end
|
|
65
71
|
end
|
|
66
72
|
|
|
67
|
-
def
|
|
68
|
-
|
|
69
|
-
tags.collect do |tag|
|
|
70
|
-
get_pact_urls(link.expand(provider: provider, tag: tag).get)
|
|
71
|
-
end.flatten
|
|
73
|
+
def index
|
|
74
|
+
@index_entity ||= Pact::Hal::Link.new({ "href" => broker_base_url }, http_client).get
|
|
72
75
|
end
|
|
73
76
|
|
|
74
|
-
def
|
|
77
|
+
def latest_pacts_for_provider
|
|
75
78
|
link = index_entity._link(LATEST_PROVIDER_RELATION)
|
|
76
|
-
|
|
79
|
+
pact_urls(link.expand(provider: provider).get)
|
|
77
80
|
end
|
|
78
81
|
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
def pact_urls(link_by_provider)
|
|
83
|
+
link_by_provider.fetch(PB_PACTS, PACTS).collect do |pact|
|
|
84
|
+
Pact::Provider::PactURI.new(pact[HREF], http_client_options)
|
|
85
|
+
end
|
|
82
86
|
end
|
|
83
87
|
|
|
84
|
-
def
|
|
85
|
-
|
|
88
|
+
def log_message
|
|
89
|
+
message = "INFO: Fetching pacts for #{provider} from #{broker_base_url}"
|
|
90
|
+
if tags.any?
|
|
91
|
+
desc = tags.collect do |tag|
|
|
92
|
+
all_or_latest = tag[:all] ? "all" : "latest"
|
|
93
|
+
name = tag[:fallback] ? "#{tag[:name]} (or #{tag[:fallback]} if not found)" : tag[:name]
|
|
94
|
+
"#{all_or_latest} #{name}"
|
|
95
|
+
end.join(", ")
|
|
96
|
+
message << " for tags: #{desc}"
|
|
97
|
+
end
|
|
98
|
+
Pact.configuration.output_stream.puts message
|
|
86
99
|
end
|
|
87
100
|
end
|
|
88
101
|
end
|
|
89
|
-
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'pact/hal/entity'
|
|
2
|
+
require 'pact/hal/http_client'
|
|
3
|
+
require 'pact/provider/pact_uri'
|
|
4
|
+
|
|
5
|
+
module Pact
|
|
6
|
+
module PactBroker
|
|
7
|
+
class FetchWipPacts
|
|
8
|
+
attr_reader :provider, :tags, :broker_base_url, :http_client_options, :http_client, :index_entity
|
|
9
|
+
|
|
10
|
+
WIP_PROVIDER_RELATION = 'beta:wip-provider-pacts'.freeze
|
|
11
|
+
PACTS = 'pacts'.freeze
|
|
12
|
+
PB_PACTS = 'pb:pacts'.freeze
|
|
13
|
+
HREF = 'href'.freeze
|
|
14
|
+
|
|
15
|
+
def initialize(provider, broker_base_url, http_client_options)
|
|
16
|
+
@provider = provider
|
|
17
|
+
@http_client_options = http_client_options
|
|
18
|
+
@broker_base_url = broker_base_url
|
|
19
|
+
@http_client = Pact::Hal::HttpClient.new(http_client_options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.call(provider, broker_base_url, http_client_options)
|
|
23
|
+
new(provider, broker_base_url, http_client_options).call
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def call
|
|
27
|
+
if index.success?
|
|
28
|
+
wip_pacts_for_provider
|
|
29
|
+
else
|
|
30
|
+
raise Pact::Error.new("Error retrieving #{broker_base_url} status=#{index_entity.response.code} #{index_entity.response.raw_body}")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def index
|
|
37
|
+
@index_entity ||= Pact::Hal::Link.new({ "href" => broker_base_url }, http_client).get
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def wip_pacts_for_provider
|
|
41
|
+
link = index_entity._link(WIP_PROVIDER_RELATION)
|
|
42
|
+
if link
|
|
43
|
+
get_pact_urls(link.expand(provider: provider).get)
|
|
44
|
+
else
|
|
45
|
+
[]
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_pact_urls(link_by_provider)
|
|
50
|
+
link_by_provider.fetch(PB_PACTS, PACTS).collect do |pact|
|
|
51
|
+
Pact::Provider::PactURI.new(pact[HREF], http_client_options)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'pact/pact_broker/fetch_pacts'
|
|
2
|
+
require 'pact/pact_broker/fetch_wip_pacts'
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# @public Use by Pact Provider Verifier
|
|
6
|
+
#
|
|
7
|
+
module Pact
|
|
8
|
+
module PactBroker
|
|
9
|
+
extend self
|
|
10
|
+
|
|
11
|
+
def fetch_pact_uris *args
|
|
12
|
+
Pact::PactBroker::FetchPacts.call(*args).collect(&:uri)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def fetch_wip_pact_uris *args
|
|
16
|
+
Pact::PactBroker::FetchWipPacts.call(*args).collect(&:uri)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'pact/shared/dsl'
|
|
2
|
+
require 'pact/provider/world'
|
|
3
|
+
require 'pact/pact_broker/fetch_pacts'
|
|
4
|
+
|
|
5
|
+
module Pact
|
|
6
|
+
module Provider
|
|
7
|
+
module Configuration
|
|
8
|
+
class PactVerificationFromBroker
|
|
9
|
+
|
|
10
|
+
extend Pact::DSL
|
|
11
|
+
|
|
12
|
+
# If user declares a variable with the same name as one of these attributes
|
|
13
|
+
# in parent scope, it will clash with these ones,
|
|
14
|
+
# so put an underscore in front of the name to be safer.
|
|
15
|
+
|
|
16
|
+
attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_basic_auth_options, :_verbose
|
|
17
|
+
|
|
18
|
+
def initialize(provider_name)
|
|
19
|
+
@_provider_name = provider_name
|
|
20
|
+
@_consumer_version_tags = []
|
|
21
|
+
@_verbose = false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
dsl do
|
|
25
|
+
def pact_broker_base_url pact_broker_base_url, basic_auth_options = {}
|
|
26
|
+
self._pact_broker_base_url = pact_broker_base_url
|
|
27
|
+
self._basic_auth_options = basic_auth_options
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def consumer_version_tags consumer_version_tags
|
|
31
|
+
self._consumer_version_tags = *consumer_version_tags
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def verbose verbose
|
|
35
|
+
self._verbose = verbose
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def finalize
|
|
40
|
+
validate
|
|
41
|
+
create_pact_verification
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def create_pact_verification
|
|
47
|
+
fetch_pacts = Pact::PactBroker::FetchPacts.new(_provider_name, _consumer_version_tags, _pact_broker_base_url, _basic_auth_options.merge(verbose: _verbose))
|
|
48
|
+
Pact.provider_world.add_pact_uri_source fetch_pacts
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def validate
|
|
52
|
+
raise Pact::Error.new("Please provide a pact_broker_base_url from which to retrieve the pacts") unless _pact_broker_base_url
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'pact/provider/configuration/pact_verification'
|
|
2
|
+
require 'pact/provider/configuration/pact_verification_from_broker'
|
|
2
3
|
require 'pact/provider/configuration/service_provider_config'
|
|
3
4
|
require 'pact/errors'
|
|
4
5
|
|
|
@@ -53,12 +54,20 @@ module Pact
|
|
|
53
54
|
def honours_pact_with consumer_name, options = {}, &block
|
|
54
55
|
create_pact_verification consumer_name, options, &block
|
|
55
56
|
end
|
|
57
|
+
|
|
58
|
+
def honours_pacts_from_pact_broker &block
|
|
59
|
+
create_pact_verification_from_broker &block
|
|
60
|
+
end
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
def create_pact_verification consumer_name, options, &block
|
|
59
64
|
PactVerification.build(consumer_name, options, &block)
|
|
60
65
|
end
|
|
61
66
|
|
|
67
|
+
def create_pact_verification_from_broker(&block)
|
|
68
|
+
PactVerificationFromBroker.build(name, &block)
|
|
69
|
+
end
|
|
70
|
+
|
|
62
71
|
def finalize
|
|
63
72
|
validate
|
|
64
73
|
create_service_provider
|
|
@@ -36,6 +36,7 @@ module Pact
|
|
|
36
36
|
ensure
|
|
37
37
|
::RSpec.reset
|
|
38
38
|
Pact.clear_provider_world
|
|
39
|
+
Pact.clear_consumer_world
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
|
|
@@ -90,7 +91,7 @@ module Pact
|
|
|
90
91
|
::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
|
|
91
92
|
.run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
|
|
92
93
|
end
|
|
93
|
-
exit_code
|
|
94
|
+
options[:wip] ? 0 : exit_code
|
|
94
95
|
end
|
|
95
96
|
|
|
96
97
|
def rspec_runner_options
|
|
@@ -118,7 +119,8 @@ module Pact
|
|
|
118
119
|
def initialize_specs
|
|
119
120
|
pact_sources.each do | pact_source |
|
|
120
121
|
options = {
|
|
121
|
-
criteria: @options[:criteria]
|
|
122
|
+
criteria: @options[:criteria],
|
|
123
|
+
wip: @options[:wip]
|
|
122
124
|
}
|
|
123
125
|
honour_pactfile pact_source.uri, ordered_pact_json(pact_source.pact_json), options
|
|
124
126
|
end
|
|
@@ -144,6 +146,8 @@ module Pact
|
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
::RSpec.configuration.full_backtrace = @options[:full_backtrace]
|
|
149
|
+
|
|
150
|
+
::RSpec.configuration.failure_color = :yellow if @options[:wip]
|
|
147
151
|
end
|
|
148
152
|
|
|
149
153
|
def ordered_pact_json(pact_json)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
module Pact::Provider
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
class PactVerification
|
|
3
|
+
attr_reader :consumer_name, :uri, :ref
|
|
4
|
+
def initialize consumer_name, uri, ref
|
|
5
|
+
@consumer_name = consumer_name
|
|
6
|
+
@uri = uri
|
|
7
|
+
@ref = ref
|
|
8
|
+
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
def == other
|
|
11
|
+
other.is_a?(PactVerification) &&
|
|
12
|
+
consumer_name == other.consumer_name &&
|
|
13
|
+
uri == other.uri &&
|
|
14
|
+
ref == other.ref
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
17
|
end
|
|
@@ -42,9 +42,21 @@ module Pact
|
|
|
42
42
|
summary.failed_examples.collect{ |e| e.metadata[:pact_interaction_example_description] }.uniq.size
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def wip?(summary)
|
|
46
|
+
summary.failed_examples.any?{ |e| e.metadata[:pact_wip] }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def failure_title summary
|
|
50
|
+
if wip?(summary)
|
|
51
|
+
"#{failed_interactions_count(summary)} pending"
|
|
52
|
+
else
|
|
53
|
+
::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
45
57
|
def totals_line summary
|
|
46
58
|
line = ::RSpec::Core::Formatters::Helpers.pluralize(interactions_count(summary), "interaction")
|
|
47
|
-
line << ", " <<
|
|
59
|
+
line << ", " << failure_title(summary)
|
|
48
60
|
line
|
|
49
61
|
end
|
|
50
62
|
|
|
@@ -57,7 +69,11 @@ module Pact
|
|
|
57
69
|
end
|
|
58
70
|
|
|
59
71
|
def print_rerun_commands summary
|
|
60
|
-
|
|
72
|
+
if wip?(summary)
|
|
73
|
+
output.puts("\nPending interactions: (Failures listed here are expected and do not affect your suite's status)\n\n")
|
|
74
|
+
else
|
|
75
|
+
output.puts("\nFailed interactions:\n\n")
|
|
76
|
+
end
|
|
61
77
|
interaction_rerun_commands(summary).each do | message |
|
|
62
78
|
output.puts(message)
|
|
63
79
|
end
|
data/lib/pact/provider/rspec.rb
CHANGED
|
@@ -21,10 +21,11 @@ module Pact
|
|
|
21
21
|
include ::RSpec::Core::DSL
|
|
22
22
|
|
|
23
23
|
def honour_pactfile pact_uri, pact_json, options
|
|
24
|
-
|
|
24
|
+
pact_description = options[:wip] ? "WIP pact" : "pact"
|
|
25
|
+
Pact.configuration.output_stream.puts "INFO: Reading #{pact_description} at #{pact_uri}"
|
|
25
26
|
Pact.configuration.output_stream.puts "INFO: Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
|
|
26
27
|
consumer_contract = Pact::ConsumerContract.from_json(pact_json)
|
|
27
|
-
::RSpec.describe "Verifying a
|
|
28
|
+
::RSpec.describe "Verifying a #{pact_description} between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}", pactfile_uri: pact_uri do
|
|
28
29
|
honour_consumer_contract consumer_contract, options.merge(pact_json: pact_json, pact_uri: pact_uri)
|
|
29
30
|
end
|
|
30
31
|
end
|
|
@@ -72,7 +73,8 @@ module Pact
|
|
|
72
73
|
pact: :verify,
|
|
73
74
|
pact_interaction: interaction,
|
|
74
75
|
pact_interaction_example_description: interaction_description_for_rerun_command(interaction),
|
|
75
|
-
pact_uri: options[:pact_uri]
|
|
76
|
+
pact_uri: options[:pact_uri],
|
|
77
|
+
pact_wip: options[:wip]
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
describe description_for(interaction), metadata do
|
data/lib/pact/provider/world.rb
CHANGED
|
@@ -29,8 +29,22 @@ module Pact
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def pact_urls
|
|
32
|
-
pact_verifications.collect(&:uri)
|
|
32
|
+
(pact_verifications.collect(&:uri) + pact_uris_from_pact_uri_sources).compact
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def add_pact_uri_source pact_uri_source
|
|
36
|
+
pact_uri_sources << pact_uri_source
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def pact_uri_sources
|
|
42
|
+
@pact_uri_sources ||= []
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def pact_uris_from_pact_uri_sources
|
|
46
|
+
pact_uri_sources.collect{| pact_uri_source| pact_uri_source.call }.flatten
|
|
33
47
|
end
|
|
34
48
|
end
|
|
35
49
|
end
|
|
36
|
-
end
|
|
50
|
+
end
|
data/lib/pact/retry.rb
CHANGED
|
@@ -10,8 +10,8 @@ module Pact
|
|
|
10
10
|
|
|
11
11
|
extend self
|
|
12
12
|
|
|
13
|
-
def execute_pact_verify pact_uri = nil, pact_helper = nil, rspec_opts = nil
|
|
14
|
-
execute_cmd verify_command(pact_helper || Pact::Provider::PactHelperLocater.pact_helper_path, pact_uri, rspec_opts)
|
|
13
|
+
def execute_pact_verify pact_uri = nil, pact_helper = nil, rspec_opts = nil, verification_opts = {}
|
|
14
|
+
execute_cmd verify_command(pact_helper || Pact::Provider::PactHelperLocater.pact_helper_path, pact_uri, rspec_opts, verification_opts)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def handle_verification_failure
|
|
@@ -19,7 +19,7 @@ module Pact
|
|
|
19
19
|
abort if exit_status != 0
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def verify_command pact_helper, pact_uri, rspec_opts
|
|
22
|
+
def verify_command pact_helper, pact_uri, rspec_opts, verification_opts
|
|
23
23
|
command_parts = []
|
|
24
24
|
# Clear SPEC_OPTS, otherwise we can get extra formatters, creating duplicate output eg. CI Reporting.
|
|
25
25
|
# Allow deliberate configuration using rspec_opts in VerificationTask.
|
|
@@ -28,6 +28,7 @@ module Pact
|
|
|
28
28
|
command_parts << "-S pact verify"
|
|
29
29
|
command_parts << "--pact-helper" << Shellwords.escape(pact_helper.end_with?(".rb") ? pact_helper : pact_helper + ".rb")
|
|
30
30
|
(command_parts << "--pact-uri" << pact_uri) if pact_uri
|
|
31
|
+
command_parts << "--wip" if verification_opts[:wip]
|
|
31
32
|
command_parts << "--pact-broker-username" << ENV['PACT_BROKER_USERNAME'] if ENV['PACT_BROKER_USERNAME']
|
|
32
33
|
command_parts << "--pact-broker-password" << ENV['PACT_BROKER_PASSWORD'] if ENV['PACT_BROKER_PASSWORD']
|
|
33
34
|
command_parts << "--backtrace" if ENV['BACKTRACE'] == 'true'
|
|
@@ -30,9 +30,11 @@ module Pact
|
|
|
30
30
|
|
|
31
31
|
attr_reader :pact_spec_configs
|
|
32
32
|
attr_accessor :rspec_opts
|
|
33
|
+
attr_accessor :wip
|
|
33
34
|
|
|
34
35
|
def initialize(name)
|
|
35
36
|
@rspec_opts = nil
|
|
37
|
+
@wip = false
|
|
36
38
|
@pact_spec_configs = []
|
|
37
39
|
@name = name
|
|
38
40
|
yield self
|
|
@@ -74,7 +76,7 @@ module Pact
|
|
|
74
76
|
require 'pact/tasks/task_helper'
|
|
75
77
|
|
|
76
78
|
exit_statuses = pact_spec_configs.collect do | config |
|
|
77
|
-
Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper], rspec_opts
|
|
79
|
+
Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper], rspec_opts, { wip: wip }
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
Pact::TaskHelper.handle_verification_failure do
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
|
|
|
33
33
|
|
|
34
34
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
|
35
35
|
gem.add_development_dependency 'webmock', '~> 3.0'
|
|
36
|
-
gem.add_development_dependency 'pry'
|
|
36
|
+
#gem.add_development_dependency 'pry-byebug'
|
|
37
37
|
gem.add_development_dependency 'fakefs', '0.5' # 0.6.0 blows up
|
|
38
38
|
gem.add_development_dependency 'hashie', '~> 2.0'
|
|
39
39
|
gem.add_development_dependency 'activesupport'
|
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.29.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: 2018-
|
|
15
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: randexp
|
|
@@ -174,20 +174,6 @@ dependencies:
|
|
|
174
174
|
- - "~>"
|
|
175
175
|
- !ruby/object:Gem::Version
|
|
176
176
|
version: '3.0'
|
|
177
|
-
- !ruby/object:Gem::Dependency
|
|
178
|
-
name: pry
|
|
179
|
-
requirement: !ruby/object:Gem::Requirement
|
|
180
|
-
requirements:
|
|
181
|
-
- - ">="
|
|
182
|
-
- !ruby/object:Gem::Version
|
|
183
|
-
version: '0'
|
|
184
|
-
type: :development
|
|
185
|
-
prerelease: false
|
|
186
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
187
|
-
requirements:
|
|
188
|
-
- - ">="
|
|
189
|
-
- !ruby/object:Gem::Version
|
|
190
|
-
version: '0'
|
|
191
177
|
- !ruby/object:Gem::Dependency
|
|
192
178
|
name: fakefs
|
|
193
179
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -335,13 +321,16 @@ files:
|
|
|
335
321
|
- lib/pact/hal/entity.rb
|
|
336
322
|
- lib/pact/hal/http_client.rb
|
|
337
323
|
- lib/pact/hal/link.rb
|
|
324
|
+
- lib/pact/pact_broker.rb
|
|
338
325
|
- lib/pact/pact_broker/fetch_pacts.rb
|
|
326
|
+
- lib/pact/pact_broker/fetch_wip_pacts.rb
|
|
339
327
|
- lib/pact/project_root.rb
|
|
340
328
|
- lib/pact/provider.rb
|
|
341
329
|
- lib/pact/provider/configuration.rb
|
|
342
330
|
- lib/pact/provider/configuration/configuration_extension.rb
|
|
343
331
|
- lib/pact/provider/configuration/dsl.rb
|
|
344
332
|
- lib/pact/provider/configuration/pact_verification.rb
|
|
333
|
+
- lib/pact/provider/configuration/pact_verification_from_broker.rb
|
|
345
334
|
- lib/pact/provider/configuration/service_provider_config.rb
|
|
346
335
|
- lib/pact/provider/configuration/service_provider_dsl.rb
|
|
347
336
|
- lib/pact/provider/context.rb
|