pact_broker-client 1.38.2 → 1.42.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +47 -0
  4. data/Gemfile +4 -0
  5. data/README.md +18 -0
  6. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +61 -140
  7. data/example/scripts/publish-pact.sh +1 -1
  8. data/lib/pact_broker/client/backports.rb +9 -0
  9. data/lib/pact_broker/client/base_client.rb +1 -1
  10. data/lib/pact_broker/client/base_command.rb +95 -0
  11. data/lib/pact_broker/client/can_i_deploy.rb +20 -3
  12. data/lib/pact_broker/client/cli/broker.rb +44 -28
  13. data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
  14. data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
  15. data/lib/pact_broker/client/cli/pacticipant_commands.rb +44 -0
  16. data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -0
  17. data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
  18. data/lib/pact_broker/client/colorize_notices.rb +31 -0
  19. data/lib/pact_broker/client/environments.rb +3 -0
  20. data/lib/pact_broker/client/environments/create_environment.rb +31 -0
  21. data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
  22. data/lib/pact_broker/client/environments/describe_environment.rb +36 -0
  23. data/lib/pact_broker/client/environments/environment_command.rb +66 -0
  24. data/lib/pact_broker/client/environments/list_environments.rb +30 -0
  25. data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
  26. data/lib/pact_broker/client/environments/update_environment.rb +31 -0
  27. data/lib/pact_broker/client/generate_display_name.rb +27 -0
  28. data/lib/pact_broker/client/hal/entity.rb +26 -3
  29. data/lib/pact_broker/client/hal/http_client.rb +11 -2
  30. data/lib/pact_broker/client/hal/link.rb +20 -0
  31. data/lib/pact_broker/client/hal/links.rb +15 -0
  32. data/lib/pact_broker/client/hal_client_methods.rb +9 -3
  33. data/lib/pact_broker/client/matrix.rb +4 -0
  34. data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
  35. data/lib/pact_broker/client/matrix/resource.rb +26 -1
  36. data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
  37. data/lib/pact_broker/client/pacticipants.rb +6 -0
  38. data/lib/pact_broker/client/pacticipants/create.rb +24 -34
  39. data/lib/pact_broker/client/pacticipants/list.rb +34 -0
  40. data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
  41. data/lib/pact_broker/client/pacts.rb +0 -1
  42. data/lib/pact_broker/client/publish_pacts.rb +94 -128
  43. data/lib/pact_broker/client/publish_pacts_the_old_way.rb +194 -0
  44. data/lib/pact_broker/client/string_refinements.rb +56 -0
  45. data/lib/pact_broker/client/tasks/publication_task.rb +3 -3
  46. data/lib/pact_broker/client/version.rb +1 -1
  47. data/lib/pact_broker/client/versions/record_deployment.rb +6 -6
  48. data/lib/pact_broker/client/versions/record_undeployment.rb +45 -68
  49. data/pact-broker-client.gemspec +2 -0
  50. data/script/approve-all.sh +6 -0
  51. data/script/publish-pact.sh +36 -5
  52. data/script/record-deployment.sh +1 -3
  53. data/script/record-undeployment.sh +4 -0
  54. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
  55. data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
  56. data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
  57. data/spec/fixtures/foo-bar.json +31 -0
  58. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
  59. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +5 -5
  60. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +36 -7
  61. data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
  62. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
  63. data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
  64. data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
  65. data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
  66. data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
  67. data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
  68. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +5 -2
  69. data/spec/lib/pact_broker/client/{publish_pacts_spec.rb → publish_pacts_the_old_way_spec.rb} +10 -9
  70. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +18 -12
  71. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +5 -5
  72. data/spec/pacts/pact_broker_client-pact_broker.json +50 -124
  73. data/spec/service_providers/create_environment_spec.rb +78 -0
  74. data/spec/service_providers/list_environments_spec.rb +77 -0
  75. data/spec/service_providers/pact_broker_client_create_version_spec.rb +4 -4
  76. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
  77. data/spec/service_providers/pacticipants_create_spec.rb +5 -4
  78. data/spec/service_providers/publish_pacts_spec.rb +116 -0
  79. data/spec/service_providers/record_deployment_spec.rb +6 -7
  80. data/spec/spec_helper.rb +3 -1
  81. data/spec/support/approvals.rb +26 -0
  82. data/spec/support/shared_context.rb +6 -2
  83. metadata +86 -5
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'webmock/rspec'
2
+ require 'rspec/its'
2
3
 
3
- ENV['PACT_BROKER_FEATURES'] = 'deployments'
4
+ ENV['PACT_BROKER_FEATURES'] = 'deployments publish_contracts ignore'
4
5
 
5
6
  WebMock.disable_net_connect!(allow_localhost: true)
6
7
 
7
8
  require "./spec/support/shared_context.rb"
9
+ require "./spec/support/approvals.rb"
8
10
 
9
11
  is_windows = (RbConfig::CONFIG['host_os'] =~ /bccwin|cygwin|djgpp|mingw|mswin|wince/i) != nil
10
12
  is_ci = ENV['CI'] == 'true'
@@ -0,0 +1,26 @@
1
+ require 'approvals/rspec'
2
+ require 'pact/support'
3
+
4
+ Approvals.configure do |c|
5
+ c.approvals_path = 'spec/fixtures/approvals/'
6
+ end
7
+
8
+ def print_diff(exception)
9
+ parts = exception.message.split('"')
10
+ received_file = parts[1]
11
+ approved_file = parts[3]
12
+ if File.exist?(received_file) && File.exist?(approved_file) && received_file.end_with?(".json") && approved_file.end_with?(".json")
13
+ received_hash = JSON.parse(File.read(received_file))
14
+ approved_hash = JSON.parse(File.read(approved_file))
15
+ diff = Pact::Matchers.diff(approved_hash, received_hash)
16
+ puts Pact::Matchers::UnixDiffFormatter.call(diff)
17
+ end
18
+ end
19
+
20
+ RSpec.configure do | config |
21
+ config.after(:each) do | example |
22
+ if example.exception.is_a?(Approvals::ApprovalError)
23
+ print_diff(example.exception)
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,11 @@
1
1
  require 'pact_broker/client/pact_hash'
2
- shared_context "pact broker" do
2
+ require 'pact_broker/client/hal/http_client'
3
3
 
4
+ shared_context "pact broker" do
5
+ before do
6
+ allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
7
+ allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
8
+ end
4
9
  let(:pact_hash) { PactBroker::Client::PactHash[consumer: {name: 'Condor'}, provider: {name: 'Pricing Service'}, interactions: []] }
5
10
  let(:consumer_contract) { Pact::ConsumerContract.from_hash pact_hash }
6
11
  let(:pact_json) { pact_hash.to_json }
@@ -16,5 +21,4 @@ shared_context "pact broker" do
16
21
  let(:put_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
17
22
  let(:post_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
18
23
  let(:get_request_headers) { { 'Accept' => 'application/hal+json'} }
19
-
20
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.38.2
4
+ version: 1.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2021-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -170,6 +170,40 @@ dependencies:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '1.16'
173
+ - !ruby/object:Gem::Dependency
174
+ name: approvals
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: 0.0.24
180
+ - - "<"
181
+ - !ruby/object:Gem::Version
182
+ version: 1.0.0
183
+ type: :development
184
+ prerelease: false
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: 0.0.24
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: 1.0.0
193
+ - !ruby/object:Gem::Dependency
194
+ name: rspec-its
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '1.3'
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: '1.3'
173
207
  description: Client for the Pact Broker. Publish, retrieve and query pacts and verification
174
208
  results.
175
209
  email:
@@ -206,16 +240,30 @@ files:
206
240
  - lib/pact_broker/client.rb
207
241
  - lib/pact_broker/client/backports.rb
208
242
  - lib/pact_broker/client/base_client.rb
243
+ - lib/pact_broker/client/base_command.rb
209
244
  - lib/pact_broker/client/can_i_deploy.rb
210
245
  - lib/pact_broker/client/cli/broker.rb
211
246
  - lib/pact_broker/client/cli/can_i_deploy_long_desc.txt
212
247
  - lib/pact_broker/client/cli/create_or_update_webhook_long_desc.txt
213
248
  - lib/pact_broker/client/cli/create_webhook_long_desc.txt
214
249
  - lib/pact_broker/client/cli/custom_thor.rb
250
+ - lib/pact_broker/client/cli/environment_commands.rb
251
+ - lib/pact_broker/client/cli/pacticipant_commands.rb
252
+ - lib/pact_broker/client/cli/record_deployment_long_desc.txt
215
253
  - lib/pact_broker/client/cli/version_selector_options_parser.rb
254
+ - lib/pact_broker/client/colorize_notices.rb
216
255
  - lib/pact_broker/client/command_result.rb
217
256
  - lib/pact_broker/client/create_tag.rb
257
+ - lib/pact_broker/client/environments.rb
258
+ - lib/pact_broker/client/environments/create_environment.rb
259
+ - lib/pact_broker/client/environments/delete_environment.rb
260
+ - lib/pact_broker/client/environments/describe_environment.rb
261
+ - lib/pact_broker/client/environments/environment_command.rb
262
+ - lib/pact_broker/client/environments/list_environments.rb
263
+ - lib/pact_broker/client/environments/text_formatter.rb
264
+ - lib/pact_broker/client/environments/update_environment.rb
218
265
  - lib/pact_broker/client/error.rb
266
+ - lib/pact_broker/client/generate_display_name.rb
219
267
  - lib/pact_broker/client/git.rb
220
268
  - lib/pact_broker/client/hal.rb
221
269
  - lib/pact_broker/client/hal/authorization_header_redactor.rb
@@ -227,6 +275,7 @@ files:
227
275
  - lib/pact_broker/client/hal_client_methods.rb
228
276
  - lib/pact_broker/client/hash_refinements.rb
229
277
  - lib/pact_broker/client/matrix.rb
278
+ - lib/pact_broker/client/matrix/abbreviate_version_number.rb
230
279
  - lib/pact_broker/client/matrix/formatter.rb
231
280
  - lib/pact_broker/client/matrix/json_formatter.rb
232
281
  - lib/pact_broker/client/matrix/resource.rb
@@ -237,10 +286,14 @@ files:
237
286
  - lib/pact_broker/client/pact_hash.rb
238
287
  - lib/pact_broker/client/pacticipants.rb
239
288
  - lib/pact_broker/client/pacticipants/create.rb
289
+ - lib/pact_broker/client/pacticipants/list.rb
290
+ - lib/pact_broker/client/pacticipants/text_formatter.rb
240
291
  - lib/pact_broker/client/pacts.rb
241
292
  - lib/pact_broker/client/pacts/list_latest_versions.rb
242
293
  - lib/pact_broker/client/publish_pacts.rb
294
+ - lib/pact_broker/client/publish_pacts_the_old_way.rb
243
295
  - lib/pact_broker/client/retry.rb
296
+ - lib/pact_broker/client/string_refinements.rb
244
297
  - lib/pact_broker/client/tasks.rb
245
298
  - lib/pact_broker/client/tasks/publication_task.rb
246
299
  - lib/pact_broker/client/version.rb
@@ -255,12 +308,18 @@ files:
255
308
  - lib/pact_broker/client/webhooks/test.rb
256
309
  - lib/pact_broker_client.rb
257
310
  - pact-broker-client.gemspec
311
+ - script/approve-all.sh
258
312
  - script/create-pacticipant.sh
259
313
  - script/generate-cli-usage.sh
260
314
  - script/publish-pact.sh
261
315
  - script/record-deployment.sh
316
+ - script/record-undeployment.sh
262
317
  - script/release.sh
263
318
  - script/trigger-release.sh
319
+ - spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
320
+ - spec/fixtures/approvals/describe_environment.approved.txt
321
+ - spec/fixtures/approvals/list_environments.approved.txt
322
+ - spec/fixtures/foo-bar.json
264
323
  - spec/integration/can_i_deploy_spec.rb
265
324
  - spec/integration/create_version_tag_spec.rb
266
325
  - spec/lib/pact_broker/client/base_client_spec.rb
@@ -272,6 +331,10 @@ files:
272
331
  - spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb
273
332
  - spec/lib/pact_broker/client/cli/custom_thor_spec.rb
274
333
  - spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb
334
+ - spec/lib/pact_broker/client/environments/delete_environment_spec.rb
335
+ - spec/lib/pact_broker/client/environments/describe_environment_spec.rb
336
+ - spec/lib/pact_broker/client/environments/update_environment_spec.rb
337
+ - spec/lib/pact_broker/client/generate_display_name_spec.rb
275
338
  - spec/lib/pact_broker/client/git_spec.rb
276
339
  - spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb
277
340
  - spec/lib/pact_broker/client/hal/entity_spec.rb
@@ -284,7 +347,7 @@ files:
284
347
  - spec/lib/pact_broker/client/pact_broker_client_spec.rb
285
348
  - spec/lib/pact_broker/client/pacticipants/create_spec.rb
286
349
  - spec/lib/pact_broker/client/pacticipants_spec.rb
287
- - spec/lib/pact_broker/client/publish_pacts_spec.rb
350
+ - spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb
288
351
  - spec/lib/pact_broker/client/retry_spec.rb
289
352
  - spec/lib/pact_broker/client/tasks/publication_task_spec.rb
290
353
  - spec/lib/pact_broker/client/versions/describe_spec.rb
@@ -292,9 +355,12 @@ files:
292
355
  - spec/lib/pact_broker/client/versions_spec.rb
293
356
  - spec/lib/pact_broker/client/webhooks/create_spec.rb
294
357
  - spec/pacts/pact_broker_client-pact_broker.json
358
+ - spec/service_providers/create_environment_spec.rb
295
359
  - spec/service_providers/extra_goodies_spec.rb
360
+ - spec/service_providers/list_environments_spec.rb
296
361
  - spec/service_providers/list_latest_pact_versions_spec.rb.bak
297
362
  - spec/service_providers/pact_broker_client_create_version_spec.rb
363
+ - spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
298
364
  - spec/service_providers/pact_broker_client_matrix_spec.rb
299
365
  - spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
300
366
  - spec/service_providers/pact_broker_client_publish_spec.rb
@@ -305,9 +371,11 @@ files:
305
371
  - spec/service_providers/pact_broker_client_versions_spec.rb
306
372
  - spec/service_providers/pact_helper.rb
307
373
  - spec/service_providers/pacticipants_create_spec.rb
374
+ - spec/service_providers/publish_pacts_spec.rb
308
375
  - spec/service_providers/record_deployment_spec.rb
309
376
  - spec/service_providers/webhooks_create_spec.rb
310
377
  - spec/spec_helper.rb
378
+ - spec/support/approvals.rb
311
379
  - spec/support/cli_test_pacts/bar.json
312
380
  - spec/support/cli_test_pacts/foo.json
313
381
  - spec/support/latest_pacts_for_provider.json
@@ -339,11 +407,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
407
  - !ruby/object:Gem::Version
340
408
  version: '0'
341
409
  requirements: []
342
- rubygems_version: 3.2.15
410
+ rubygems_version: 3.2.18
343
411
  signing_key:
344
412
  specification_version: 4
345
413
  summary: See description
346
414
  test_files:
415
+ - spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
416
+ - spec/fixtures/approvals/describe_environment.approved.txt
417
+ - spec/fixtures/approvals/list_environments.approved.txt
418
+ - spec/fixtures/foo-bar.json
347
419
  - spec/integration/can_i_deploy_spec.rb
348
420
  - spec/integration/create_version_tag_spec.rb
349
421
  - spec/lib/pact_broker/client/base_client_spec.rb
@@ -355,6 +427,10 @@ test_files:
355
427
  - spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb
356
428
  - spec/lib/pact_broker/client/cli/custom_thor_spec.rb
357
429
  - spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb
430
+ - spec/lib/pact_broker/client/environments/delete_environment_spec.rb
431
+ - spec/lib/pact_broker/client/environments/describe_environment_spec.rb
432
+ - spec/lib/pact_broker/client/environments/update_environment_spec.rb
433
+ - spec/lib/pact_broker/client/generate_display_name_spec.rb
358
434
  - spec/lib/pact_broker/client/git_spec.rb
359
435
  - spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb
360
436
  - spec/lib/pact_broker/client/hal/entity_spec.rb
@@ -367,7 +443,7 @@ test_files:
367
443
  - spec/lib/pact_broker/client/pact_broker_client_spec.rb
368
444
  - spec/lib/pact_broker/client/pacticipants/create_spec.rb
369
445
  - spec/lib/pact_broker/client/pacticipants_spec.rb
370
- - spec/lib/pact_broker/client/publish_pacts_spec.rb
446
+ - spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb
371
447
  - spec/lib/pact_broker/client/retry_spec.rb
372
448
  - spec/lib/pact_broker/client/tasks/publication_task_spec.rb
373
449
  - spec/lib/pact_broker/client/versions/describe_spec.rb
@@ -375,9 +451,12 @@ test_files:
375
451
  - spec/lib/pact_broker/client/versions_spec.rb
376
452
  - spec/lib/pact_broker/client/webhooks/create_spec.rb
377
453
  - spec/pacts/pact_broker_client-pact_broker.json
454
+ - spec/service_providers/create_environment_spec.rb
378
455
  - spec/service_providers/extra_goodies_spec.rb
456
+ - spec/service_providers/list_environments_spec.rb
379
457
  - spec/service_providers/list_latest_pact_versions_spec.rb.bak
380
458
  - spec/service_providers/pact_broker_client_create_version_spec.rb
459
+ - spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
381
460
  - spec/service_providers/pact_broker_client_matrix_spec.rb
382
461
  - spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
383
462
  - spec/service_providers/pact_broker_client_publish_spec.rb
@@ -388,9 +467,11 @@ test_files:
388
467
  - spec/service_providers/pact_broker_client_versions_spec.rb
389
468
  - spec/service_providers/pact_helper.rb
390
469
  - spec/service_providers/pacticipants_create_spec.rb
470
+ - spec/service_providers/publish_pacts_spec.rb
391
471
  - spec/service_providers/record_deployment_spec.rb
392
472
  - spec/service_providers/webhooks_create_spec.rb
393
473
  - spec/spec_helper.rb
474
+ - spec/support/approvals.rb
394
475
  - spec/support/cli_test_pacts/bar.json
395
476
  - spec/support/cli_test_pacts/foo.json
396
477
  - spec/support/latest_pacts_for_provider.json