pact_broker-client 1.25.1 → 1.27.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release_gem.yml +35 -0
  3. data/.github/workflows/trigger_pact_cli_release.yml +15 -0
  4. data/.github/workflows/trigger_pact_docs_update.yml +19 -0
  5. data/CHANGELOG.md +39 -0
  6. data/Gemfile +10 -1
  7. data/README.md +4 -3
  8. data/appveyor.yml +1 -1
  9. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +168 -10
  10. data/lib/pact_broker/client/can_i_deploy.rb +6 -0
  11. data/lib/pact_broker/client/cli/broker.rb +32 -0
  12. data/lib/pact_broker/client/cli/custom_thor.rb +12 -1
  13. data/lib/pact_broker/client/git.rb +2 -1
  14. data/lib/pact_broker/client/hal/entity.rb +12 -1
  15. data/lib/pact_broker/client/hal/http_client.rb +6 -0
  16. data/lib/pact_broker/client/hal/link.rb +4 -0
  17. data/lib/pact_broker/client/hal_client_methods.rb +15 -0
  18. data/lib/pact_broker/client/matrix/resource.rb +5 -1
  19. data/lib/pact_broker/client/pacticipants/create.rb +57 -0
  20. data/lib/pact_broker/client/pacts/list_latest_versions.rb +65 -0
  21. data/lib/pact_broker/client/publish_pacts.rb +1 -1
  22. data/lib/pact_broker/client/version.rb +1 -1
  23. data/lib/pact_broker/client/webhooks/test.rb +16 -0
  24. data/pact-broker-client.gemspec +3 -5
  25. data/script/prepare-release.sh +11 -0
  26. data/script/release-gem.sh +23 -0
  27. data/script/release.sh +1 -1
  28. data/script/trigger-release.sh +15 -0
  29. data/spec/integration/can_i_deploy_spec.rb +3 -3
  30. data/spec/integration/create_version_tag_spec.rb +2 -3
  31. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +22 -4
  32. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +28 -0
  33. data/spec/pacts/pact_broker_client-pact_broker.json +179 -10
  34. data/spec/service_providers/pact_broker_client_matrix_spec.rb +10 -10
  35. data/spec/service_providers/pact_helper.rb +29 -0
  36. data/spec/service_providers/pacticipants_create_spec.rb +118 -0
  37. metadata +29 -44
@@ -58,12 +58,41 @@ module PactBrokerPactHelperMethods
58
58
  _links: {
59
59
  :'pb:webhooks' => {
60
60
  href: placeholder_url_term('pb:webhooks')
61
+ },
62
+ :'pb:pacticipants' => {
63
+ href: placeholder_url_term('pb:pacticipants')
64
+ },
65
+ :'pb:pacticipant' => {
66
+ href: placeholder_url_term('pb:pacticipant', ['pacticipant'])
61
67
  }
62
68
  }
63
69
  }
64
70
  )
65
71
  end
66
72
 
73
+ def mock_pact_broker_index_with_relations(context, links, provider_state)
74
+ _links = links.each_with_object({}) do | (key, value), new_links |
75
+ new_links[key] = {
76
+ href: value
77
+ }
78
+ end
79
+
80
+ pact_broker
81
+ .given(provider_state)
82
+ .upon_receiving("a request for the index resource")
83
+ .with(
84
+ method: :get,
85
+ path: '/',
86
+ headers: context.get_request_headers).
87
+ will_respond_with(
88
+ status: 200,
89
+ headers: context.pact_broker_response_headers,
90
+ body: {
91
+ _links: _links
92
+ }
93
+ )
94
+ end
95
+
67
96
  def mock_pact_broker_index_with_webhook_relation(context)
68
97
  pact_broker
69
98
  .upon_receiving("a request for the index resource with the webhook relation")
@@ -0,0 +1,118 @@
1
+ require_relative 'pact_helper'
2
+ require 'pact_broker/client/pacticipants/create'
3
+
4
+ RSpec.describe "creating or updating a pacticipant", pact: true do
5
+ include_context "pact broker"
6
+ include PactBrokerPactHelperMethods
7
+
8
+ before do
9
+ index_links = {
10
+ 'pb:pacticipants' => Pact.term('http://localhost:1234/pacticipants', %r{http://.*}),
11
+ 'pb:pacticipant' => Pact.term('http://localhost:1234/pacticipants/{pacticipant}', %r{http://.*\{pacticipant\}}),
12
+ }
13
+ mock_pact_broker_index_with_relations(self, index_links, "the pacticipant relations are present")
14
+ end
15
+
16
+ let(:params) do
17
+ {
18
+ name: "Foo",
19
+ repository_url: "http://foo"
20
+ }
21
+ end
22
+
23
+ let(:request_body) { { name: "Foo", repositoryUrl: "http://foo" } }
24
+
25
+
26
+ let(:response_status) { 201 }
27
+ let(:create_success_response) do
28
+ {
29
+ status: response_status,
30
+ headers: pact_broker_response_headers,
31
+ body: {
32
+ name: "Foo",
33
+ repositoryUrl: "http://foo",
34
+ _links: {
35
+ self: {
36
+ href: Pact.term('http://localhost:1234/pacticipants/Foo', %r{http://.*}),
37
+ }
38
+ }
39
+ }
40
+ }
41
+ end
42
+
43
+ let(:get_success_response) do
44
+ {
45
+ status: 200,
46
+ headers: pact_broker_response_headers,
47
+ body: {
48
+ _links: {
49
+ self: {
50
+ href: Pact.term('http://localhost:1234/pacticipants/Foo', %r{http://.*}),
51
+ }
52
+ }
53
+ }
54
+ }
55
+ end
56
+
57
+ let(:pact_broker_client_options) { {} }
58
+
59
+ subject { PactBroker::Client::Pacticipants2::Create.call(params, broker_base_url, pact_broker_client_options) }
60
+
61
+ context "when the pacticipant does not already exist" do
62
+ before do
63
+ pact_broker
64
+ .upon_receiving("a request to retrieve a pacticipant")
65
+ .with(
66
+ method: :get,
67
+ path: '/pacticipants/Foo',
68
+ headers: get_request_headers)
69
+ .will_respond_with(status: 404)
70
+
71
+ pact_broker
72
+ .upon_receiving("a request to create a pacticipant")
73
+ .with(
74
+ method: :post,
75
+ path: '/pacticipants',
76
+ headers: post_request_headers,
77
+ body: request_body)
78
+ .will_respond_with(create_success_response)
79
+ end
80
+
81
+ it "returns a CommandResult with success = true" do
82
+ expect(subject).to be_a PactBroker::Client::CommandResult
83
+ expect(subject.success).to be true
84
+ expect(subject.message).to eq "Pacticipant \"Foo\" created"
85
+ end
86
+ end
87
+
88
+ context "when the pacticipant does already exist" do
89
+ before do
90
+ pact_broker
91
+ .given("a pacticipant with name Foo exists")
92
+ .upon_receiving("a request to retrieve a pacticipant")
93
+ .with(
94
+ method: :get,
95
+ path: '/pacticipants/Foo',
96
+ headers: get_request_headers)
97
+ .will_respond_with(get_success_response)
98
+
99
+ pact_broker
100
+ .given("a pacticipant with name Foo exists")
101
+ .upon_receiving("a request to update a pacticipant")
102
+ .with(
103
+ method: :patch,
104
+ path: '/pacticipants/Foo',
105
+ headers: post_request_headers,
106
+ body: request_body)
107
+ .will_respond_with(create_success_response)
108
+ end
109
+
110
+ let(:response_status) { 200 }
111
+
112
+ it "returns a CommandResult with success = true" do
113
+ expect(subject).to be_a PactBroker::Client::CommandResult
114
+ expect(subject.success).to be true
115
+ expect(subject.message).to eq "Pacticipant \"Foo\" updated"
116
+ end
117
+ end
118
+ end
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.25.1
4
+ version: 1.27.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: json
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '0'
19
+ version: '0.18'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ">="
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: '0.18'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: term-ansicolor
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ">="
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: '1.7'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '1.7'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: table_print
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +70,16 @@ dependencies:
84
70
  name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '13.0'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '13.0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: fakefs
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +136,6 @@ dependencies:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
138
  version: '1.16'
153
- - !ruby/object:Gem::Dependency
154
- name: bump
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0.5'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '0.5'
167
139
  description: Client for the Pact Broker. Publish, retrieve and query pacts and verification
168
140
  results.
169
141
  email:
@@ -173,6 +145,9 @@ executables:
173
145
  extensions: []
174
146
  extra_rdoc_files: []
175
147
  files:
148
+ - ".github/workflows/release_gem.yml"
149
+ - ".github/workflows/trigger_pact_cli_release.yml"
150
+ - ".github/workflows/trigger_pact_docs_update.yml"
176
151
  - ".gitignore"
177
152
  - ".rspec"
178
153
  - ".travis.yml"
@@ -213,6 +188,7 @@ files:
213
188
  - lib/pact_broker/client/hal/entry_point.rb
214
189
  - lib/pact_broker/client/hal/http_client.rb
215
190
  - lib/pact_broker/client/hal/link.rb
191
+ - lib/pact_broker/client/hal_client_methods.rb
216
192
  - lib/pact_broker/client/matrix.rb
217
193
  - lib/pact_broker/client/matrix/formatter.rb
218
194
  - lib/pact_broker/client/matrix/json_formatter.rb
@@ -223,7 +199,9 @@ files:
223
199
  - lib/pact_broker/client/pact_file.rb
224
200
  - lib/pact_broker/client/pact_hash.rb
225
201
  - lib/pact_broker/client/pacticipants.rb
202
+ - lib/pact_broker/client/pacticipants/create.rb
226
203
  - lib/pact_broker/client/pacts.rb
204
+ - lib/pact_broker/client/pacts/list_latest_versions.rb
227
205
  - lib/pact_broker/client/publish_pacts.rb
228
206
  - lib/pact_broker/client/retry.rb
229
207
  - lib/pact_broker/client/tasks.rb
@@ -235,11 +213,15 @@ files:
235
213
  - lib/pact_broker/client/versions/json_formatter.rb
236
214
  - lib/pact_broker/client/versions/text_formatter.rb
237
215
  - lib/pact_broker/client/webhooks/create.rb
216
+ - lib/pact_broker/client/webhooks/test.rb
238
217
  - lib/pact_broker_client.rb
239
218
  - pact-broker-client.gemspec
240
219
  - script/generate-cli-usage.sh
220
+ - script/prepare-release.sh
241
221
  - script/publish-pact.sh
222
+ - script/release-gem.sh
242
223
  - script/release.sh
224
+ - script/trigger-release.sh
243
225
  - spec/integration/can_i_deploy_spec.rb
244
226
  - spec/integration/create_version_tag_spec.rb
245
227
  - spec/lib/pact_broker/client/base_client_spec.rb
@@ -261,6 +243,7 @@ files:
261
243
  - spec/lib/pact_broker/client/matrix_spec.rb
262
244
  - spec/lib/pact_broker/client/merge_pacts_spec.rb
263
245
  - spec/lib/pact_broker/client/pact_broker_client_spec.rb
246
+ - spec/lib/pact_broker/client/pacticipants/create_spec.rb
264
247
  - spec/lib/pact_broker/client/pacticipants_spec.rb
265
248
  - spec/lib/pact_broker/client/publish_pacts_spec.rb
266
249
  - spec/lib/pact_broker/client/retry_spec.rb
@@ -279,6 +262,7 @@ files:
279
262
  - spec/service_providers/pact_broker_client_tags_spec.rb
280
263
  - spec/service_providers/pact_broker_client_versions_spec.rb
281
264
  - spec/service_providers/pact_helper.rb
265
+ - spec/service_providers/pacticipants_create_spec.rb
282
266
  - spec/service_providers/webhooks_create_spec.rb
283
267
  - spec/spec_helper.rb
284
268
  - spec/support/cli_test_pacts/bar.json
@@ -311,8 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
295
  - !ruby/object:Gem::Version
312
296
  version: '0'
313
297
  requirements: []
314
- rubyforge_project:
315
- rubygems_version: 2.7.6
298
+ rubygems_version: 3.0.6
316
299
  signing_key:
317
300
  specification_version: 4
318
301
  summary: See description
@@ -338,6 +321,7 @@ test_files:
338
321
  - spec/lib/pact_broker/client/matrix_spec.rb
339
322
  - spec/lib/pact_broker/client/merge_pacts_spec.rb
340
323
  - spec/lib/pact_broker/client/pact_broker_client_spec.rb
324
+ - spec/lib/pact_broker/client/pacticipants/create_spec.rb
341
325
  - spec/lib/pact_broker/client/pacticipants_spec.rb
342
326
  - spec/lib/pact_broker/client/publish_pacts_spec.rb
343
327
  - spec/lib/pact_broker/client/retry_spec.rb
@@ -356,6 +340,7 @@ test_files:
356
340
  - spec/service_providers/pact_broker_client_tags_spec.rb
357
341
  - spec/service_providers/pact_broker_client_versions_spec.rb
358
342
  - spec/service_providers/pact_helper.rb
343
+ - spec/service_providers/pacticipants_create_spec.rb
359
344
  - spec/service_providers/webhooks_create_spec.rb
360
345
  - spec/spec_helper.rb
361
346
  - spec/support/cli_test_pacts/bar.json