pact_broker-client 1.38.3 → 1.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) 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 +57 -18
  6. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +182 -2
  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_command.rb +95 -0
  10. data/lib/pact_broker/client/can_i_deploy.rb +20 -3
  11. data/lib/pact_broker/client/cli/broker.rb +41 -28
  12. data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
  13. data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
  14. data/lib/pact_broker/client/cli/pacticipant_commands.rb +44 -0
  15. data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -0
  16. data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
  17. data/lib/pact_broker/client/colorize_notices.rb +31 -0
  18. data/lib/pact_broker/client/environments.rb +3 -0
  19. data/lib/pact_broker/client/environments/create_environment.rb +31 -0
  20. data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
  21. data/lib/pact_broker/client/environments/describe_environment.rb +36 -0
  22. data/lib/pact_broker/client/environments/environment_command.rb +66 -0
  23. data/lib/pact_broker/client/environments/list_environments.rb +30 -0
  24. data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
  25. data/lib/pact_broker/client/environments/update_environment.rb +31 -0
  26. data/lib/pact_broker/client/generate_display_name.rb +27 -0
  27. data/lib/pact_broker/client/hal/entity.rb +26 -3
  28. data/lib/pact_broker/client/hal/http_client.rb +11 -2
  29. data/lib/pact_broker/client/hal/link.rb +20 -0
  30. data/lib/pact_broker/client/hal/links.rb +15 -0
  31. data/lib/pact_broker/client/hal_client_methods.rb +9 -3
  32. data/lib/pact_broker/client/matrix.rb +4 -0
  33. data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
  34. data/lib/pact_broker/client/matrix/resource.rb +26 -1
  35. data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
  36. data/lib/pact_broker/client/pacticipants.rb +6 -0
  37. data/lib/pact_broker/client/pacticipants/create.rb +24 -34
  38. data/lib/pact_broker/client/pacticipants/list.rb +34 -0
  39. data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
  40. data/lib/pact_broker/client/pacts.rb +0 -1
  41. data/lib/pact_broker/client/publish_pacts.rb +94 -128
  42. data/lib/pact_broker/client/publish_pacts_the_old_way.rb +194 -0
  43. data/lib/pact_broker/client/string_refinements.rb +56 -0
  44. data/lib/pact_broker/client/tasks/publication_task.rb +3 -3
  45. data/lib/pact_broker/client/version.rb +1 -1
  46. data/lib/pact_broker/client/versions/record_deployment.rb +14 -38
  47. data/lib/pact_broker/client/versions/record_undeployment.rb +45 -68
  48. data/pact-broker-client.gemspec +2 -0
  49. data/script/approve-all.sh +6 -0
  50. data/script/publish-pact.sh +36 -5
  51. data/script/record-deployment.sh +1 -3
  52. data/script/record-undeployment.sh +4 -0
  53. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
  54. data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
  55. data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
  56. data/spec/fixtures/foo-bar.json +31 -0
  57. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
  58. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +5 -5
  59. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +36 -7
  60. data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
  61. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
  62. data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
  63. data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
  64. data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
  65. data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
  66. data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
  67. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +5 -2
  68. data/spec/lib/pact_broker/client/{publish_pacts_spec.rb → publish_pacts_the_old_way_spec.rb} +10 -9
  69. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +18 -12
  70. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +17 -24
  71. data/spec/pacts/pact_broker_client-pact_broker.json +197 -2
  72. data/spec/service_providers/create_environment_spec.rb +78 -0
  73. data/spec/service_providers/list_environments_spec.rb +77 -0
  74. data/spec/service_providers/pact_broker_client_create_version_spec.rb +4 -4
  75. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
  76. data/spec/service_providers/pacticipants_create_spec.rb +5 -4
  77. data/spec/service_providers/publish_pacts_spec.rb +116 -0
  78. data/spec/service_providers/record_deployment_spec.rb +14 -11
  79. data/spec/spec_helper.rb +3 -1
  80. data/spec/support/approvals.rb +26 -0
  81. data/spec/support/shared_context.rb +6 -2
  82. metadata +86 -5
@@ -0,0 +1,78 @@
1
+ require 'service_providers/pact_helper'
2
+ require 'pact_broker/client/environments/create_environment'
3
+
4
+ RSpec.describe "create an environment", pact: true, skip: true do
5
+ include_context "pact broker"
6
+ include PactBrokerPactHelperMethods
7
+
8
+ let(:params) do
9
+ {
10
+ name: "test",
11
+ display_name: "Test",
12
+ production: false,
13
+ contact_name: "Foo team",
14
+ contact_email_address: "foo@bar.com"
15
+
16
+ }
17
+ end
18
+ let(:pact_broker_client_options) { {} }
19
+ let(:request_body) do
20
+ {
21
+ name: "test",
22
+ displayName: "Test",
23
+ production: false,
24
+ contacts: [{
25
+ name: "Foo team",
26
+ details: {
27
+ emailAddress: "foo@bar.com"
28
+ }
29
+ }]
30
+ }
31
+ end
32
+
33
+ subject { PactBroker::Client::Environments::CreateEnvironment.call(params, broker_base_url, pact_broker_client_options) }
34
+
35
+ def mock_index
36
+ pact_broker
37
+ .given("the pb:environments relation exists in the index resource")
38
+ .upon_receiving("a request for the index resource")
39
+ .with(
40
+ method: "GET",
41
+ path: '/',
42
+ headers: get_request_headers).
43
+ will_respond_with(
44
+ status: 200,
45
+ headers: pact_broker_response_headers,
46
+ body: {
47
+ _links: {
48
+ :'pb:environments' => {
49
+ href: placeholder_url_term("pb:environments")
50
+ }
51
+ }
52
+ }
53
+ )
54
+ end
55
+
56
+ def mock_environment_creation_request
57
+ pact_broker
58
+ .upon_receiving("a request to create an environment")
59
+ .with(
60
+ method: "POST",
61
+ path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
62
+ headers: post_request_headers,
63
+ body: request_body
64
+ )
65
+ .will_respond_with(
66
+ status: 201,
67
+ headers: pact_broker_response_headers,
68
+ body: request_body.merge("uuid" => Pact.like("ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"))
69
+ )
70
+ end
71
+
72
+ it "returns a success result" do
73
+ mock_index
74
+ mock_environment_creation_request
75
+ expect(subject.success).to be true
76
+ expect(subject.message).to include "Created test environment in the Pact Broker with UUID ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"
77
+ end
78
+ end
@@ -0,0 +1,77 @@
1
+ require 'service_providers/pact_helper'
2
+ require 'pact_broker/client/environments/list_environments'
3
+
4
+ RSpec.describe "list environments", pact: true, skip: true do
5
+ include_context "pact broker"
6
+ include PactBrokerPactHelperMethods
7
+
8
+ let(:params) { { output: output } }
9
+ let(:output) { "text" }
10
+ let(:pact_broker_client_options) { {} }
11
+ let(:response_body) do
12
+ {
13
+ _embedded: {
14
+ environments: Pact.each_like(
15
+ {
16
+ uuid: "78e85fb2-9df1-48da-817e-c9bea6294e01",
17
+ name: "test",
18
+ displayName: "Test",
19
+ production: false,
20
+ contacts: [{
21
+ name: "Foo team",
22
+ details: {
23
+ emailAddress: "foo@bar.com"
24
+ }
25
+ }]
26
+ }
27
+ )
28
+ }
29
+ }
30
+ end
31
+
32
+ subject { PactBroker::Client::Environments::ListEnvironments.call(params, broker_base_url, pact_broker_client_options) }
33
+
34
+ def mock_index
35
+ pact_broker
36
+ .given("the pb:environments relation exists in the index resource")
37
+ .upon_receiving("a request for the index resource")
38
+ .with(
39
+ method: "GET",
40
+ path: '/',
41
+ headers: get_request_headers).
42
+ will_respond_with(
43
+ status: 200,
44
+ headers: pact_broker_response_headers,
45
+ body: {
46
+ _links: {
47
+ :'pb:environments' => {
48
+ href: placeholder_url_term("pb:environments")
49
+ }
50
+ }
51
+ }
52
+ )
53
+ end
54
+
55
+ def mock_get_environments
56
+ pact_broker
57
+ .given("an environment exists")
58
+ .upon_receiving("a request to list the environments")
59
+ .with(
60
+ method: "GET",
61
+ path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
62
+ headers: get_request_headers
63
+ )
64
+ .will_respond_with(
65
+ status: 200,
66
+ headers: pact_broker_response_headers,
67
+ body: response_body
68
+ )
69
+ end
70
+
71
+ it "returns a success result" do
72
+ mock_index
73
+ mock_get_environments
74
+ expect(subject.success).to be true
75
+ Approvals.verify(subject.message, :name => "list_environments", format: :txt)
76
+ end
77
+ end
@@ -1,6 +1,6 @@
1
1
  require_relative 'pact_helper'
2
2
  require 'pact_broker/client'
3
- require 'pact_broker/client/publish_pacts'
3
+ require 'pact_broker/client/publish_pacts_the_old_way'
4
4
 
5
5
  describe PactBroker::Client::Versions, pact: true do
6
6
 
@@ -9,7 +9,7 @@ describe PactBroker::Client::Versions, pact: true do
9
9
 
10
10
  describe "creating a pacticipant version" do
11
11
  before do
12
- allow(publish_pacts).to receive(:consumer_names).and_return(["Foo"])
12
+ allow(publish_pacts_the_old_way).to receive(:consumer_names).and_return(["Foo"])
13
13
  allow($stdout).to receive(:puts)
14
14
  end
15
15
  let(:version_path) { "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}" }
@@ -18,11 +18,11 @@ describe PactBroker::Client::Versions, pact: true do
18
18
  let(:branch) { "main" }
19
19
  let(:build_url) { "http://my-ci/builds/1" }
20
20
  let(:consumer_version_params) { { number: number, branch: branch, build_url: build_url } }
21
- let(:publish_pacts) { PactBroker::Client::PublishPacts.new(pact_broker.mock_service_base_url, ["some-pact.json"], consumer_version_params, {}) }
21
+ let(:publish_pacts_the_old_way) { PactBroker::Client::PublishPactsTheOldWay.new(pact_broker.mock_service_base_url, ["some-pact.json"], consumer_version_params, {}) }
22
22
  let(:provider_state) { "version #{number} of pacticipant Foo does not exist" }
23
23
  let(:expected_response_status) { 201 }
24
24
 
25
- subject { publish_pacts.send(:create_consumer_versions) }
25
+ subject { publish_pacts_the_old_way.send(:create_consumer_versions) }
26
26
 
27
27
  before do
28
28
  pact_broker
@@ -0,0 +1,98 @@
1
+ require_relative 'pact_helper'
2
+ require 'pact_broker/client/can_i_deploy'
3
+
4
+ module PactBroker::Client
5
+ describe Matrix, :pact => true do
6
+
7
+ include_context "pact broker"
8
+
9
+ describe "can-i-deploy ignoring a pacticipant version" do
10
+ let(:matrix_response_body) { matrix }
11
+ let(:matrix) do
12
+ {
13
+ "summary" => {
14
+ "deployable" => true,
15
+ "ignored" => 1
16
+ },
17
+ "notices" => Pact.each_like("text" => "some notice", "type" => "info"),
18
+ "matrix" => [
19
+ {
20
+ "consumer" => {
21
+ "name" => "Foo",
22
+ "version" => {
23
+ "number" => "1.2.3"
24
+ }
25
+ },
26
+ "provider" => {
27
+ "name" => "Bar",
28
+ "version" => {
29
+ "number" => "4.5.6"
30
+ }
31
+ },
32
+ "verificationResult" => {
33
+ "success" => true,
34
+ "_links" => {
35
+ "self" => {
36
+ "href" => Pact.like("http://result")
37
+ }
38
+ }
39
+ }
40
+ },{
41
+ "consumer" => {
42
+ "name" => "Foo",
43
+ "version" => {
44
+ "number" => "3.4.5"
45
+ }
46
+ },
47
+ "provider" => {
48
+ "name" => "Bar",
49
+ "version" => {
50
+ "number" => "4.5.6"
51
+ }
52
+ },
53
+ "verificationResult" => {
54
+ "success" => false,
55
+ "_links" => {
56
+ "self" => {
57
+ "href" => Pact.like("http://result")
58
+ }
59
+ }
60
+ },
61
+ "ignored" => true
62
+ }
63
+ ]
64
+ }
65
+
66
+ end
67
+ let(:selectors) { [{ pacticipant: "Bar", version: "4.5.6" }, { pacticipant: "Foo", tag: "prod" } ] }
68
+ let(:matrix_options) do
69
+ {
70
+ ignore_selectors: [{ pacticipant: "Foo", version: "3.4.5" }]
71
+ }
72
+ end
73
+ let(:options) { { retry_while_unknown: 0, output: 'table' } }
74
+
75
+ before do
76
+ pact_broker
77
+ .given("provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod")
78
+ .upon_receiving("a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5")
79
+ .with(
80
+ method: :get,
81
+ path: "/matrix",
82
+ query: "q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Btag%5D=prod&latestby=cvpv&ignore%5B%5D%5Bpacticipant%5D=Foo&ignore%5B%5D%5Bversion%5D=3.4.5"
83
+ )
84
+ .will_respond_with(
85
+ status: 200,
86
+ headers: pact_broker_response_headers,
87
+ body: matrix_response_body
88
+ )
89
+ end
90
+
91
+ subject { PactBroker::Client::CanIDeploy.call(broker_base_url, selectors, matrix_options, options, {})}
92
+
93
+ it 'returns the CLI output' do
94
+ Approvals.verify(subject.message, :name => "can_i_deploy_ignore", format: :txt)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -54,9 +54,10 @@ RSpec.describe "creating or updating a pacticipant", pact: true do
54
54
  }
55
55
  end
56
56
 
57
- let(:pact_broker_client_options) { {} }
57
+ let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url} }
58
+ let(:options) { {} }
58
59
 
59
- subject { PactBroker::Client::Pacticipants2::Create.call(params, broker_base_url, pact_broker_client_options) }
60
+ subject { PactBroker::Client::Pacticipants2::Create.call(params, options, pact_broker_client_options) }
60
61
 
61
62
  context "when the pacticipant does not already exist" do
62
63
  before do
@@ -81,7 +82,7 @@ RSpec.describe "creating or updating a pacticipant", pact: true do
81
82
  it "returns a CommandResult with success = true" do
82
83
  expect(subject).to be_a PactBroker::Client::CommandResult
83
84
  expect(subject.success).to be true
84
- expect(subject.message).to eq "Pacticipant \"Foo\" created"
85
+ expect(subject.message).to include "Pacticipant \"Foo\" created"
85
86
  end
86
87
  end
87
88
 
@@ -112,7 +113,7 @@ RSpec.describe "creating or updating a pacticipant", pact: true do
112
113
  it "returns a CommandResult with success = true" do
113
114
  expect(subject).to be_a PactBroker::Client::CommandResult
114
115
  expect(subject.success).to be true
115
- expect(subject.message).to eq "Pacticipant \"Foo\" updated"
116
+ expect(subject.message).to include "Pacticipant \"Foo\" updated"
116
117
  end
117
118
  end
118
119
  end
@@ -0,0 +1,116 @@
1
+ require 'pact_broker/client/publish_pacts'
2
+ require 'service_providers/pact_helper'
3
+
4
+ RSpec.describe "publishing contracts", pact: true 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
9
+ include_context "pact broker"
10
+ include PactBrokerPactHelperMethods
11
+
12
+ let(:pacticipant_name) { "Foo" }
13
+ let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
14
+ let(:output) { "text" }
15
+ let(:build_url) { "http://build" }
16
+ let(:consumer_version_params) do
17
+ {
18
+ pacticipant_name: pacticipant_name,
19
+ number: version_number,
20
+ tags: ["dev"],
21
+ branch: "main",
22
+ build_url: build_url,
23
+ output: output
24
+ }
25
+ end
26
+ let(:pact_file_path_1) { "spec/fixtures/foo-bar.json" }
27
+ let(:pact_file_paths) { [pact_file_path_1] }
28
+ let(:options) { {} }
29
+ let(:pact_broker_client_options) { {} }
30
+ let(:expected_content) { Base64.strict_encode64(JSON.parse(File.read(pact_file_path_1)).to_json) }
31
+ let(:request_body) do
32
+ {
33
+ pacticipantName: pacticipant_name,
34
+ pacticipantVersionNumber: version_number,
35
+ branch: "main",
36
+ tags: ["dev"],
37
+ buildUrl: "http://build",
38
+ contracts: [
39
+ {
40
+ consumerName: pacticipant_name,
41
+ providerName: "Bar",
42
+ specification: "pact",
43
+ contentType: "application/json",
44
+ content: expected_content,
45
+ writeMode: "overwrite",
46
+ onConflict: "overwrite"
47
+ }
48
+ ]
49
+ }
50
+ end
51
+
52
+ subject { PactBroker::Client::PublishPacts.call(broker_base_url, pact_file_paths, consumer_version_params, options, pact_broker_client_options) }
53
+
54
+ def mock_index
55
+ pact_broker
56
+ .given("the pb:publish-contracts relations exists in the index resource")
57
+ .upon_receiving("a request for the index resource")
58
+ .with(
59
+ method: "GET",
60
+ path: '/',
61
+ headers: get_request_headers).
62
+ will_respond_with(
63
+ status: 200,
64
+ headers: pact_broker_response_headers,
65
+ body: {
66
+ _links: {
67
+ :'pb:publish-contracts' => {
68
+ href: placeholder_url_term("pb:publish-contracts")
69
+ }
70
+ }
71
+ }
72
+ )
73
+ end
74
+
75
+ def mock_contract_publication
76
+ pact_broker
77
+ .upon_receiving("a request to publish contracts")
78
+ .with(
79
+ method: "POST",
80
+ path: '/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS',
81
+ headers: post_request_headers,
82
+ body: request_body).
83
+ will_respond_with(
84
+ status: 200,
85
+ headers: pact_broker_response_headers,
86
+ body: {
87
+ _embedded: {
88
+ pacticipant: {
89
+ name: pacticipant_name
90
+ },
91
+ version: {
92
+ number: version_number,
93
+ buildUrl: build_url
94
+ }
95
+ },
96
+ logs: Pact.each_like(level: "info", message: "some message"),
97
+ _links: {
98
+ :'pb:pacticipant-version-tags' => [{ name: "dev"} ],
99
+ :'pb:contracts' => [{ href: Pact.like("http://some-pact") }]
100
+ }
101
+ }
102
+ )
103
+ end
104
+
105
+ context "with valid params" do
106
+ before do
107
+ mock_index
108
+ mock_contract_publication
109
+ end
110
+
111
+ it "returns a success result" do
112
+ expect(subject.success).to be true
113
+ expect(subject.message).to include "some message"
114
+ end
115
+ end
116
+ end
@@ -2,7 +2,6 @@ require 'service_providers/pact_helper'
2
2
  require 'pact_broker/client/versions/record_deployment'
3
3
 
4
4
  RSpec.describe "recording a deployment", pact: true do
5
-
6
5
  include_context "pact broker"
7
6
  include PactBrokerPactHelperMethods
8
7
 
@@ -10,19 +9,23 @@ RSpec.describe "recording a deployment", pact: true do
10
9
  let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
11
10
  let(:environment_name) { "test" }
12
11
  let(:output) { "text" }
13
- let(:replaced_previous_deployed_version) { true }
12
+ let(:target) { "blue" }
14
13
  let(:params) do
15
14
  {
16
15
  pacticipant_name: pacticipant_name,
17
16
  version_number: version_number,
18
17
  environment_name: environment_name,
19
- replaced_previous_deployed_version: replaced_previous_deployed_version,
18
+ target: target
19
+ }
20
+ end
21
+ let(:options) do
22
+ {
20
23
  output: output
21
24
  }
22
25
  end
23
- let(:pact_broker_client_options) { {} }
26
+ let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url } }
24
27
 
25
- subject { PactBroker::Client::Versions::RecordDeployment.call(params, broker_base_url, pact_broker_client_options) }
28
+ subject { PactBroker::Client::Versions::RecordDeployment.call(params, options, pact_broker_client_options) }
26
29
 
27
30
  def mock_index
28
31
  pact_broker
@@ -148,14 +151,14 @@ RSpec.describe "recording a deployment", pact: true do
148
151
  path: "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
149
152
  headers: post_request_headers,
150
153
  body: {
151
- replacedPreviousDeployedVersion: replaced_previous_deployed_version
154
+ target: target
152
155
  }
153
156
  )
154
157
  .will_respond_with(
155
158
  status: 201,
156
159
  headers: pact_broker_response_headers,
157
160
  body: {
158
- replacedPreviousDeployedVersion: replaced_previous_deployed_version
161
+ target: target
159
162
  }
160
163
  )
161
164
  end
@@ -169,14 +172,14 @@ RSpec.describe "recording a deployment", pact: true do
169
172
 
170
173
  it "returns a success message" do
171
174
  expect(subject.success).to be true
172
- expect(subject.message).to eq "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test in the Pact Broker. Marked previous deployed version as undeployed."
175
+ expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (target blue) in the Pact Broker."
173
176
  end
174
177
 
175
178
  context "when the output is json" do
176
179
  let(:output) { "json" }
177
180
 
178
181
  it "returns the JSON payload" do
179
- expect(JSON.parse(subject.message)).to eq "replacedPreviousDeployedVersion" => replaced_previous_deployed_version
182
+ expect(JSON.parse(subject.message)).to eq "target" => target
180
183
  end
181
184
  end
182
185
  end
@@ -205,14 +208,14 @@ RSpec.describe "recording a deployment", pact: true do
205
208
 
206
209
  it "returns an error response" do
207
210
  expect(subject.success).to be false
208
- expect(subject.message).to eq "No environment found with name 'foo'. Available options: test"
211
+ expect(subject.message).to include "No environment found with name 'foo'. Available options: test"
209
212
  end
210
213
  end
211
214
 
212
215
  context "when the specified environment does exist" do
213
216
  it "returns an error response" do
214
217
  expect(subject.success).to be false
215
- expect(subject.message).to eq "Environment 'test' is not an available option for recording a deployment of Foo. Available options: prod, dev"
218
+ expect(subject.message).to include "Environment 'test' is not an available option for recording a deployment of Foo. Available options: prod, dev"
216
219
  end
217
220
  end
218
221
  end