pact 1.40.0 → 1.49.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 +5 -5
- data/CHANGELOG.md +172 -0
- data/lib/pact/cli/run_pact_verification.rb +23 -7
- data/lib/pact/consumer/configuration/dsl.rb +0 -1
- data/lib/pact/consumer/spec_hooks.rb +2 -2
- data/lib/pact/doc/sort_interactions.rb +2 -3
- data/lib/pact/hal/authorization_header_redactor.rb +32 -0
- data/lib/pact/hal/http_client.rb +17 -6
- data/lib/pact/hal/link.rb +50 -13
- data/lib/pact/hal/non_json_entity.rb +28 -0
- data/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb +102 -0
- data/lib/pact/pact_broker/notices.rb +34 -0
- data/lib/pact/pact_broker.rb +10 -4
- data/lib/pact/provider/configuration/dsl.rb +6 -1
- data/lib/pact/provider/configuration/message_provider_dsl.rb +32 -0
- data/lib/pact/provider/configuration/pact_verification_from_broker.rb +22 -4
- data/lib/pact/provider/configuration/service_provider_dsl.rb +1 -1
- data/lib/pact/provider/help/content.rb +4 -4
- data/lib/pact/provider/help/pact_diff.rb +10 -34
- data/lib/pact/provider/help/write.rb +6 -7
- data/lib/pact/provider/pact_helper_locator.rb +13 -11
- data/lib/pact/provider/pact_source.rb +10 -1
- data/lib/pact/provider/pact_spec_runner.rb +24 -16
- data/lib/pact/provider/pact_uri.rb +6 -4
- data/lib/pact/provider/request.rb +1 -1
- data/lib/pact/provider/rspec/formatter_rspec_3.rb +1 -1
- data/lib/pact/provider/rspec/json_formatter.rb +98 -0
- data/lib/pact/provider/rspec/pact_broker_formatter.rb +1 -1
- data/lib/pact/provider/rspec.rb +17 -7
- data/lib/pact/provider/test_methods.rb +1 -1
- 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/provider/world.rb +1 -1
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +17 -13
- metadata +60 -59
- data/lib/pact/pact_broker/fetch_pending_pacts.rb +0 -58
|
@@ -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/provider/world.rb
CHANGED
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'pact/version'
|
|
5
4
|
|
|
@@ -15,30 +14,35 @@ Gem::Specification.new do |gem|
|
|
|
15
14
|
gem.required_ruby_version = '>= 2.0'
|
|
16
15
|
|
|
17
16
|
gem.files = `git ls-files bin lib pact.gemspec CHANGELOG.md LICENSE.txt`.split($/)
|
|
18
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
19
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
20
19
|
gem.require_paths = ["lib"]
|
|
21
20
|
gem.license = 'MIT'
|
|
22
21
|
|
|
23
|
-
gem.
|
|
24
|
-
|
|
22
|
+
gem.metadata = {
|
|
23
|
+
'changelog_uri' => 'https://github.com/pact-foundation/pact-ruby/blob/master/CHANGELOG.md',
|
|
24
|
+
'source_code_uri' => 'https://github.com/pact-foundation/pact-ruby',
|
|
25
|
+
'bug_tracker_uri' => 'https://github.com/pact-foundation/pact-ruby/issues',
|
|
26
|
+
'documentation_uri' => 'https://github.com/pact-foundation/pact-ruby/blob/master/README.md'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
gem.add_runtime_dependency 'rspec', '~> 3.0'
|
|
25
30
|
gem.add_runtime_dependency 'rack-test', '>= 0.6.3', '< 2.0.0'
|
|
26
|
-
gem.add_runtime_dependency 'thor'
|
|
27
|
-
gem.add_runtime_dependency '
|
|
28
|
-
gem.add_runtime_dependency 'webrick'
|
|
31
|
+
gem.add_runtime_dependency 'thor', '~> 0.20'
|
|
32
|
+
gem.add_runtime_dependency 'webrick', '~> 1.3'
|
|
29
33
|
gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
|
|
30
34
|
|
|
31
35
|
gem.add_runtime_dependency 'pact-support', '~> 1.9'
|
|
32
|
-
gem.add_runtime_dependency 'pact-mock_service', '~> 3.0'
|
|
36
|
+
gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
|
|
33
37
|
|
|
34
|
-
gem.add_development_dependency 'rake', '~> 10.0
|
|
38
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
|
35
39
|
gem.add_development_dependency 'webmock', '~> 3.0'
|
|
36
|
-
#gem.add_development_dependency 'pry-byebug'
|
|
37
40
|
gem.add_development_dependency 'fakefs', '0.5' # 0.6.0 blows up
|
|
38
41
|
gem.add_development_dependency 'hashie', '~> 2.0'
|
|
39
|
-
gem.add_development_dependency 'activesupport'
|
|
42
|
+
gem.add_development_dependency 'activesupport', '~> 5.2'
|
|
40
43
|
gem.add_development_dependency 'faraday', '~> 0.13'
|
|
41
|
-
gem.add_development_dependency 'appraisal', '~> 2.2'
|
|
42
44
|
gem.add_development_dependency 'conventional-changelog', '~> 1.3'
|
|
43
45
|
gem.add_development_dependency 'bump', '~> 0.5'
|
|
46
|
+
gem.add_development_dependency 'pact-message', '~> 0.6'
|
|
47
|
+
gem.add_development_dependency 'rspec-its', '~> 1.3'
|
|
44
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.49.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Fraser
|
|
@@ -12,36 +12,22 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date:
|
|
15
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
|
-
name:
|
|
18
|
+
name: rspec
|
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
|
20
20
|
requirements:
|
|
21
21
|
- - "~>"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: 0
|
|
23
|
+
version: '3.0'
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
27
|
requirements:
|
|
28
28
|
- - "~>"
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
version: 0
|
|
31
|
-
- !ruby/object:Gem::Dependency
|
|
32
|
-
name: rspec
|
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
|
34
|
-
requirements:
|
|
35
|
-
- - ">="
|
|
36
|
-
- !ruby/object:Gem::Version
|
|
37
|
-
version: '2.14'
|
|
38
|
-
type: :runtime
|
|
39
|
-
prerelease: false
|
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
requirements:
|
|
42
|
-
- - ">="
|
|
43
|
-
- !ruby/object:Gem::Version
|
|
44
|
-
version: '2.14'
|
|
30
|
+
version: '3.0'
|
|
45
31
|
- !ruby/object:Gem::Dependency
|
|
46
32
|
name: rack-test
|
|
47
33
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,44 +52,30 @@ dependencies:
|
|
|
66
52
|
name: thor
|
|
67
53
|
requirement: !ruby/object:Gem::Requirement
|
|
68
54
|
requirements:
|
|
69
|
-
- - "
|
|
70
|
-
- !ruby/object:Gem::Version
|
|
71
|
-
version: '0'
|
|
72
|
-
type: :runtime
|
|
73
|
-
prerelease: false
|
|
74
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
75
|
-
requirements:
|
|
76
|
-
- - ">="
|
|
77
|
-
- !ruby/object:Gem::Version
|
|
78
|
-
version: '0'
|
|
79
|
-
- !ruby/object:Gem::Dependency
|
|
80
|
-
name: json
|
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
|
82
|
-
requirements:
|
|
83
|
-
- - ">"
|
|
55
|
+
- - "~>"
|
|
84
56
|
- !ruby/object:Gem::Version
|
|
85
|
-
version:
|
|
57
|
+
version: '0.20'
|
|
86
58
|
type: :runtime
|
|
87
59
|
prerelease: false
|
|
88
60
|
version_requirements: !ruby/object:Gem::Requirement
|
|
89
61
|
requirements:
|
|
90
|
-
- - "
|
|
62
|
+
- - "~>"
|
|
91
63
|
- !ruby/object:Gem::Version
|
|
92
|
-
version:
|
|
64
|
+
version: '0.20'
|
|
93
65
|
- !ruby/object:Gem::Dependency
|
|
94
66
|
name: webrick
|
|
95
67
|
requirement: !ruby/object:Gem::Requirement
|
|
96
68
|
requirements:
|
|
97
|
-
- - "
|
|
69
|
+
- - "~>"
|
|
98
70
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: '
|
|
71
|
+
version: '1.3'
|
|
100
72
|
type: :runtime
|
|
101
73
|
prerelease: false
|
|
102
74
|
version_requirements: !ruby/object:Gem::Requirement
|
|
103
75
|
requirements:
|
|
104
|
-
- - "
|
|
76
|
+
- - "~>"
|
|
105
77
|
- !ruby/object:Gem::Version
|
|
106
|
-
version: '
|
|
78
|
+
version: '1.3'
|
|
107
79
|
- !ruby/object:Gem::Dependency
|
|
108
80
|
name: term-ansicolor
|
|
109
81
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -139,6 +111,9 @@ dependencies:
|
|
|
139
111
|
- - "~>"
|
|
140
112
|
- !ruby/object:Gem::Version
|
|
141
113
|
version: '3.0'
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: 3.3.1
|
|
142
117
|
type: :runtime
|
|
143
118
|
prerelease: false
|
|
144
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -146,20 +121,23 @@ dependencies:
|
|
|
146
121
|
- - "~>"
|
|
147
122
|
- !ruby/object:Gem::Version
|
|
148
123
|
version: '3.0'
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: 3.3.1
|
|
149
127
|
- !ruby/object:Gem::Dependency
|
|
150
128
|
name: rake
|
|
151
129
|
requirement: !ruby/object:Gem::Requirement
|
|
152
130
|
requirements:
|
|
153
131
|
- - "~>"
|
|
154
132
|
- !ruby/object:Gem::Version
|
|
155
|
-
version: 10.0
|
|
133
|
+
version: '10.0'
|
|
156
134
|
type: :development
|
|
157
135
|
prerelease: false
|
|
158
136
|
version_requirements: !ruby/object:Gem::Requirement
|
|
159
137
|
requirements:
|
|
160
138
|
- - "~>"
|
|
161
139
|
- !ruby/object:Gem::Version
|
|
162
|
-
version: 10.0
|
|
140
|
+
version: '10.0'
|
|
163
141
|
- !ruby/object:Gem::Dependency
|
|
164
142
|
name: webmock
|
|
165
143
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -206,16 +184,16 @@ dependencies:
|
|
|
206
184
|
name: activesupport
|
|
207
185
|
requirement: !ruby/object:Gem::Requirement
|
|
208
186
|
requirements:
|
|
209
|
-
- - "
|
|
187
|
+
- - "~>"
|
|
210
188
|
- !ruby/object:Gem::Version
|
|
211
|
-
version: '
|
|
189
|
+
version: '5.2'
|
|
212
190
|
type: :development
|
|
213
191
|
prerelease: false
|
|
214
192
|
version_requirements: !ruby/object:Gem::Requirement
|
|
215
193
|
requirements:
|
|
216
|
-
- - "
|
|
194
|
+
- - "~>"
|
|
217
195
|
- !ruby/object:Gem::Version
|
|
218
|
-
version: '
|
|
196
|
+
version: '5.2'
|
|
219
197
|
- !ruby/object:Gem::Dependency
|
|
220
198
|
name: faraday
|
|
221
199
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -231,47 +209,61 @@ dependencies:
|
|
|
231
209
|
- !ruby/object:Gem::Version
|
|
232
210
|
version: '0.13'
|
|
233
211
|
- !ruby/object:Gem::Dependency
|
|
234
|
-
name:
|
|
212
|
+
name: conventional-changelog
|
|
235
213
|
requirement: !ruby/object:Gem::Requirement
|
|
236
214
|
requirements:
|
|
237
215
|
- - "~>"
|
|
238
216
|
- !ruby/object:Gem::Version
|
|
239
|
-
version: '
|
|
217
|
+
version: '1.3'
|
|
240
218
|
type: :development
|
|
241
219
|
prerelease: false
|
|
242
220
|
version_requirements: !ruby/object:Gem::Requirement
|
|
243
221
|
requirements:
|
|
244
222
|
- - "~>"
|
|
245
223
|
- !ruby/object:Gem::Version
|
|
246
|
-
version: '
|
|
224
|
+
version: '1.3'
|
|
247
225
|
- !ruby/object:Gem::Dependency
|
|
248
|
-
name:
|
|
226
|
+
name: bump
|
|
249
227
|
requirement: !ruby/object:Gem::Requirement
|
|
250
228
|
requirements:
|
|
251
229
|
- - "~>"
|
|
252
230
|
- !ruby/object:Gem::Version
|
|
253
|
-
version: '
|
|
231
|
+
version: '0.5'
|
|
254
232
|
type: :development
|
|
255
233
|
prerelease: false
|
|
256
234
|
version_requirements: !ruby/object:Gem::Requirement
|
|
257
235
|
requirements:
|
|
258
236
|
- - "~>"
|
|
259
237
|
- !ruby/object:Gem::Version
|
|
260
|
-
version: '
|
|
238
|
+
version: '0.5'
|
|
261
239
|
- !ruby/object:Gem::Dependency
|
|
262
|
-
name:
|
|
240
|
+
name: pact-message
|
|
263
241
|
requirement: !ruby/object:Gem::Requirement
|
|
264
242
|
requirements:
|
|
265
243
|
- - "~>"
|
|
266
244
|
- !ruby/object:Gem::Version
|
|
267
|
-
version: '0.
|
|
245
|
+
version: '0.6'
|
|
268
246
|
type: :development
|
|
269
247
|
prerelease: false
|
|
270
248
|
version_requirements: !ruby/object:Gem::Requirement
|
|
271
249
|
requirements:
|
|
272
250
|
- - "~>"
|
|
273
251
|
- !ruby/object:Gem::Version
|
|
274
|
-
version: '0.
|
|
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'
|
|
275
267
|
description: Enables consumer driven contract testing, providing a mock service and
|
|
276
268
|
DSL for the consumer project, and interaction playback and verification for the
|
|
277
269
|
service provider project.
|
|
@@ -318,17 +310,21 @@ files:
|
|
|
318
310
|
- lib/pact/doc/markdown/interaction.erb
|
|
319
311
|
- lib/pact/doc/markdown/interaction_renderer.rb
|
|
320
312
|
- lib/pact/doc/sort_interactions.rb
|
|
313
|
+
- lib/pact/hal/authorization_header_redactor.rb
|
|
321
314
|
- lib/pact/hal/entity.rb
|
|
322
315
|
- lib/pact/hal/http_client.rb
|
|
323
316
|
- lib/pact/hal/link.rb
|
|
317
|
+
- lib/pact/hal/non_json_entity.rb
|
|
324
318
|
- lib/pact/pact_broker.rb
|
|
319
|
+
- lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
|
|
325
320
|
- lib/pact/pact_broker/fetch_pacts.rb
|
|
326
|
-
- lib/pact/pact_broker/
|
|
321
|
+
- lib/pact/pact_broker/notices.rb
|
|
327
322
|
- lib/pact/project_root.rb
|
|
328
323
|
- lib/pact/provider.rb
|
|
329
324
|
- lib/pact/provider/configuration.rb
|
|
330
325
|
- lib/pact/provider/configuration/configuration_extension.rb
|
|
331
326
|
- lib/pact/provider/configuration/dsl.rb
|
|
327
|
+
- lib/pact/provider/configuration/message_provider_dsl.rb
|
|
332
328
|
- lib/pact/provider/configuration/pact_verification.rb
|
|
333
329
|
- lib/pact/provider/configuration/pact_verification_from_broker.rb
|
|
334
330
|
- lib/pact/provider/configuration/service_provider_config.rb
|
|
@@ -352,6 +348,7 @@ files:
|
|
|
352
348
|
- lib/pact/provider/rspec/custom_options_file
|
|
353
349
|
- lib/pact/provider/rspec/formatter_rspec_2.rb
|
|
354
350
|
- lib/pact/provider/rspec/formatter_rspec_3.rb
|
|
351
|
+
- lib/pact/provider/rspec/json_formatter.rb
|
|
355
352
|
- lib/pact/provider/rspec/matchers.rb
|
|
356
353
|
- lib/pact/provider/rspec/pact_broker_formatter.rb
|
|
357
354
|
- lib/pact/provider/state/provider_state.rb
|
|
@@ -379,7 +376,11 @@ files:
|
|
|
379
376
|
homepage: https://github.com/pact-foundation/pact-ruby
|
|
380
377
|
licenses:
|
|
381
378
|
- MIT
|
|
382
|
-
metadata:
|
|
379
|
+
metadata:
|
|
380
|
+
changelog_uri: https://github.com/pact-foundation/pact-ruby/blob/master/CHANGELOG.md
|
|
381
|
+
source_code_uri: https://github.com/pact-foundation/pact-ruby
|
|
382
|
+
bug_tracker_uri: https://github.com/pact-foundation/pact-ruby/issues
|
|
383
|
+
documentation_uri: https://github.com/pact-foundation/pact-ruby/blob/master/README.md
|
|
383
384
|
post_install_message:
|
|
384
385
|
rdoc_options: []
|
|
385
386
|
require_paths:
|
|
@@ -396,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
396
397
|
version: '0'
|
|
397
398
|
requirements: []
|
|
398
399
|
rubyforge_project:
|
|
399
|
-
rubygems_version: 2.
|
|
400
|
+
rubygems_version: 2.7.7
|
|
400
401
|
signing_key:
|
|
401
402
|
specification_version: 4
|
|
402
403
|
summary: Enables consumer driven contract testing, providing a mock service and DSL
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require 'pact/hal/entity'
|
|
2
|
-
require 'pact/hal/http_client'
|
|
3
|
-
require 'pact/provider/pact_uri'
|
|
4
|
-
require 'pact/errors'
|
|
5
|
-
|
|
6
|
-
module Pact
|
|
7
|
-
module PactBroker
|
|
8
|
-
class FetchPendingPacts
|
|
9
|
-
attr_reader :provider, :tags, :broker_base_url, :http_client_options, :http_client, :index_entity
|
|
10
|
-
|
|
11
|
-
PENDING_PROVIDER_RELATION = 'beta:pending-provider-pacts'.freeze
|
|
12
|
-
WIP_PROVIDER_RELATION = 'beta:wip-provider-pacts'.freeze # deprecated
|
|
13
|
-
PACTS = 'pacts'.freeze
|
|
14
|
-
PB_PACTS = 'pb:pacts'.freeze
|
|
15
|
-
HREF = 'href'.freeze
|
|
16
|
-
|
|
17
|
-
def initialize(provider, broker_base_url, http_client_options)
|
|
18
|
-
@provider = provider
|
|
19
|
-
@http_client_options = http_client_options
|
|
20
|
-
@broker_base_url = broker_base_url
|
|
21
|
-
@http_client = Pact::Hal::HttpClient.new(http_client_options)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.call(provider, broker_base_url, http_client_options)
|
|
25
|
-
new(provider, broker_base_url, http_client_options).call
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def call
|
|
29
|
-
if index.success?
|
|
30
|
-
pending_pacts_for_provider
|
|
31
|
-
else
|
|
32
|
-
raise Pact::Error.new("Error retrieving #{broker_base_url} status=#{index_entity.response.code} #{index_entity.response.raw_body}")
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def index
|
|
39
|
-
@index_entity ||= Pact::Hal::Link.new({ "href" => broker_base_url }, http_client).get.assert_success!
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def pending_pacts_for_provider
|
|
43
|
-
link = index_entity._link(WIP_PROVIDER_RELATION, PENDING_PROVIDER_RELATION)
|
|
44
|
-
if link
|
|
45
|
-
get_pact_urls(link.expand(provider: provider).get)
|
|
46
|
-
else
|
|
47
|
-
[]
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def get_pact_urls(link_by_provider)
|
|
52
|
-
link_by_provider.fetch(PB_PACTS, PACTS).collect do |pact|
|
|
53
|
-
Pact::Provider::PactURI.new(pact[HREF], http_client_options)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|