pact_broker-client 1.49.0 → 1.51.2

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.
@@ -25,14 +25,13 @@ module PactBroker
25
25
  @branch = consumer_version_params[:branch]
26
26
  @build_url = consumer_version_params[:build_url]
27
27
  @tags = consumer_version_params[:tags] ? consumer_version_params[:tags].collect{ |tag| tag.respond_to?(:strip) ? tag.strip : tag } : []
28
- @version_required = consumer_version_params[:version_required]
29
28
  @pact_broker_client_options = pact_broker_client_options
30
29
  end
31
30
 
32
31
  def call
33
32
  validate
34
33
  $stdout.puts("")
35
- result = create_consumer_versions && apply_tags && publish_pacts
34
+ result = apply_tags && publish_pacts
36
35
  $stdout.puts("")
37
36
  if result
38
37
  PactBroker::Client::CommandResult.new(true)
@@ -59,10 +58,6 @@ module PactBroker
59
58
  end
60
59
  end
61
60
 
62
- def can_create_version_with_branch?
63
- @can_create_version_with_branch ||= index_resource.can?('pb:pacticipant-version')
64
- end
65
-
66
61
  def merge_on_server?
67
62
  pact_broker_client_options[:write] == :merge
68
63
  end
@@ -96,49 +91,6 @@ module PactBroker
96
91
  end
97
92
  end
98
93
 
99
- def create_consumer_versions
100
- if create_versions?
101
- consumer_names.collect do | consumer_name |
102
- create_version(index_resource, consumer_name)
103
- end
104
- true
105
- else
106
- true
107
- end
108
- end
109
-
110
- def create_versions?
111
- if version_required
112
- if can_create_version_with_branch?
113
- true
114
- else
115
- raise PactBroker::Client::Error.new("This version of the Pact Broker does not support versions with branches or build URLs. Please upgrade your broker to 2.76.2 or later.")
116
- end
117
- elsif (branch || build_url) && can_create_version_with_branch?
118
- true
119
- else
120
- false
121
- end
122
- end
123
-
124
- def create_version(index_resource, consumer_name)
125
- Retry.while_error do
126
- version_resource = index_resource._link('pb:pacticipant-version').expand(version: consumer_version_number, pacticipant: consumer_name).put(version_body).assert_success!
127
- message = if version_resource.response.status == 200
128
- "Replaced version #{consumer_version_number} of #{consumer_name}"
129
- else
130
- "Created version #{consumer_version_number} of #{consumer_name}"
131
- end
132
-
133
- message = message + " (branch #{branch})" if branch
134
- $stdout.puts message
135
- if version_resource.response.status == 200
136
- $stdout.puts ::Term::ANSIColor.yellow("Replacing the version resource is not recommended under normal circumstances and may indicate that you have not configured your Pact pipeline correctly (unless you are just re-running a build for a particular commit). For more information see https://docs.pact.io/versioning")
137
- end
138
- true
139
- end
140
- end
141
-
142
94
  def version_body
143
95
  {
144
96
  branch: branch,
@@ -185,6 +137,9 @@ module PactBroker
185
137
  end
186
138
 
187
139
  def validate
140
+ if branch || build_url
141
+ $stdout.puts ::Term::ANSIColor.yellow("WARN: This version of the Pact Broker does not support versions with branches or build URLs. Please upgrade your broker to 2.86.0 or later.")
142
+ end
188
143
  raise PactBroker::Client::Error.new("Please specify the consumer_version_number") unless (consumer_version_number && consumer_version_number.to_s.strip.size > 0)
189
144
  raise PactBroker::Client::Error.new("Please specify the pact_broker_base_url") unless (pact_broker_base_url && pact_broker_base_url.to_s.strip.size > 0)
190
145
  raise PactBroker::Client::Error.new("No pact files found") unless (pact_file_paths && pact_file_paths.any?)
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.49.0'
3
+ VERSION = '1.51.2'
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.require_paths = ["lib"]
22
22
  gem.license = 'MIT'
23
23
 
24
- gem.add_runtime_dependency 'httparty', '~>0.18'
24
+ gem.add_runtime_dependency 'httparty', '~>0.18.1' # https://github.com/jnunemaker/httparty/issues/733
25
25
  gem.add_runtime_dependency 'term-ansicolor', '~> 1.7'
26
26
  gem.add_runtime_dependency 'table_print', '~> 1.5'
27
27
  gem.add_runtime_dependency 'thor', '>= 0.20', '< 2.0'
@@ -28,7 +28,7 @@ bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
28
28
  # --contract-published
29
29
 
30
30
 
31
- PACT_BROKER_FEATURES=publish_contracts bundle exec bin/pact-broker publish spec/pacts/pact_broker_client-pact_broker.json \
31
+ bundle exec bin/pact-broker publish spec/pacts/pact_broker_client-pact_broker.json \
32
32
  --consumer-app-version 1.2.26 \
33
33
  --broker-base-url http://localhost:9292 \
34
34
  --broker-token localhost \
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env ruby
2
+ require "stringio"
3
+ require "pact_broker/client/cli/broker"
4
+
5
+ ENV["THOR_COLUMNS"] = "160"
6
+ START_MARKER = "<!-- start-autogenerated-docs -->"
7
+ END_MARKER = "<!-- end-autogenerated-docs -->"
8
+ TERMINAL_WIDTH = 80
9
+
10
+ def print_wrapped(message, options = {})
11
+ out = StringIO.new
12
+ indent = options[:indent] || 0
13
+ width = TERMINAL_WIDTH - indent
14
+ paras = message.split("\n\n")
15
+
16
+ paras.map! do |unwrapped|
17
+ counter = 0
18
+ unwrapped.split(" ").inject do |memo, word|
19
+ word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
20
+ counter = 0 if word.include? "\n"
21
+ if (counter + word.length + 1) < width
22
+ memo = "#{memo} #{word}"
23
+ counter += (word.length + 1)
24
+ else
25
+ memo = "#{memo}\n#{word}"
26
+ counter = word.length
27
+ end
28
+ memo
29
+ end
30
+ end.compact!
31
+
32
+ paras.each do |para|
33
+ para.split("\n").each do |line|
34
+ out.puts line.insert(0, " " * indent)
35
+ end
36
+ out.puts unless para == paras.last
37
+ end
38
+ out.string
39
+ end
40
+
41
+ def format_banner(banner)
42
+ banner_lines = print_wrapped(banner, indent: 16).split("\n")
43
+ banner_lines[0] = banner_lines[0].gsub(/^\s\s/, "")
44
+ banner_lines
45
+ end
46
+
47
+ def generate_thor_docs
48
+ begin
49
+ out = StringIO.new
50
+ $stdout = out
51
+
52
+ command_groups = [
53
+ ["Pacts", %w[publish list-latest-pact-versions] ],
54
+ ["Environments", %w[create-environment update-environment describe-environment delete-environment list-environments]],
55
+ ["Deployments", %w[record-deployment record-undeployment]],
56
+ ["Releases", %w[record-release record-support-ended]],
57
+ ["Matrix", %w[can-i-deploy]],
58
+ ["Pacticipants", %w[create-or-update-pacticipant describe-pacticipant list-pacticipants]],
59
+ ["Webhooks", %w[create-webhook create-or-update-webhook test-webhook]],
60
+ ["Tags", %w[create-version-tag]],
61
+ ["Versions", %w[describe-version]],
62
+ ["Miscellaneous", %w[generate-uuid]]
63
+ ]
64
+
65
+ command_groups.collect do | group, commands |
66
+ puts "### #{group}\n\n"
67
+ commands.each do | command |
68
+ puts "#### #{command}\n\n"
69
+ PactBroker::Client::CLI::Broker.start(["help", command])
70
+ puts "\n"
71
+ end
72
+ end
73
+ out.string
74
+ ensure
75
+ $stdout = STDOUT
76
+ end
77
+ end
78
+
79
+ STATES = {
80
+ start: {
81
+ /^Usage:/ => :usage
82
+ },
83
+ usage: {
84
+ /^Options:/ => :options
85
+ },
86
+ options: {
87
+ /^$/ => :after_options
88
+ },
89
+ after_options: {
90
+ /^Usage:/ => :usage
91
+ }
92
+ }
93
+
94
+ def entered?(state)
95
+ @old_state != state && @current_state == state
96
+ end
97
+
98
+ def exited?(state)
99
+ @old_state == state && @current_state != state
100
+ end
101
+
102
+ def has_option_and_banner(line)
103
+ line =~ /--.*\s#\s/
104
+ end
105
+
106
+ def has_only_banner(line)
107
+ line =~ /^\s+#\s/
108
+ end
109
+
110
+ @current_state = :start
111
+ @old_state = nil
112
+
113
+ def reformat_docs(generated_thor_docs)
114
+ generated_thor_docs.split("\n").collect do | line |
115
+ @old_state = @current_state
116
+
117
+ transitions = STATES[@current_state]
118
+
119
+ line_starts_with = transitions.keys.find { | key | line =~ key }
120
+ if line_starts_with
121
+ @current_state = transitions[line_starts_with]
122
+ end
123
+
124
+
125
+ lines = if has_option_and_banner(line)
126
+ option, banner = line.split("#", 2)
127
+ [option] + format_banner("# " + banner)
128
+ elsif has_only_banner(line)
129
+ space, banner = line.split("#", 2)
130
+ format_banner("# " + banner)
131
+ else
132
+ [line]
133
+ end
134
+
135
+ if entered?(:usage) || exited?(:options)
136
+ ["```"] + lines
137
+ else
138
+ lines
139
+ end
140
+ # line
141
+ end.flatten.join("\n").gsub("/go/", "/").gsub(File.basename(__FILE__), "pact-broker")
142
+ end
143
+
144
+ def update_readme(usage_docs)
145
+ readme_text = File.read("README.md")
146
+ before_text = readme_text.split(START_MARKER).first
147
+ after_text = readme_text.split("<!-- end-autogenerated-docs -->", 2).last
148
+ new_readme_text = before_text + START_MARKER + "\n\n" + usage_docs + "\n\n" + END_MARKER + after_text
149
+ File.open("README.md", "w") { |file| file << new_readme_text }
150
+ end
151
+
152
+ update_readme(reformat_docs(generate_thor_docs))
@@ -0,0 +1,42 @@
1
+
2
+ require 'pact_broker/client/matrix/abbreviate_version_number'
3
+
4
+ module PactBroker
5
+ module Client
6
+ describe Matrix::AbbreviateVersionNumber do
7
+ describe '.call' do
8
+ subject(:result) { described_class.call(version) }
9
+
10
+ context 'when version is nil' do
11
+ let(:version) { nil }
12
+ it { is_expected.to be_nil }
13
+ end
14
+
15
+ context 'when version is git sha' do
16
+ let(:version) { '182f9c6e4d7a5779c4507cb8b3e505ac927d0394' }
17
+ it { is_expected.to eq('182f9c6...') }
18
+ end
19
+
20
+ context 'when version is too long' do
21
+ let(:version) { '182f9c6e4d7a5779c4507cb8b3e505ac927d0394' * 2 }
22
+ it { is_expected.to eq(version[0...60] + '...') }
23
+ end
24
+
25
+ context 'when the version is something unknown and fits max length' do
26
+ let(:version) { '123' }
27
+ it { is_expected.to eq('123') }
28
+ end
29
+
30
+ context 'when version is embedded into semantic version v1' do
31
+ let(:version) { 'v1.3.4+182f9c6e4d7a5779c4507cb8b3e505ac927d0394' }
32
+ it { is_expected.to eq('v1.3.4+182f9c6...') }
33
+ end
34
+
35
+ context 'when version is embedded into semantic version v2' do
36
+ let(:version) { '1.3.4(182f9c6e4d7a5779c4507cb8b3e505ac927d0394)' }
37
+ it { is_expected.to eq('1.3.4(182f9c6...)') }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -263,80 +263,9 @@ module PactBroker
263
263
  context "when the broker does not support creation of a version with a branch but a branch is specified" do
264
264
  let(:branch) { "main" }
265
265
 
266
- context "when version_required is true" do
267
- let(:version_required) { true }
268
-
269
- it "raises an error" do
270
- expect { subject.call }.to raise_error PactBroker::Client::Error
271
- end
272
- end
273
- end
274
-
275
- context "when the broker supports creation of a version with a branch" do
276
- before do
277
- allow(version_link).to receive(:expand).and_return(version_link)
278
- allow(version_resource).to receive(:assert_success!).and_return(version_resource)
279
- allow(version_resource).to receive_message_chain(:response, :status).and_return(version_creation_response_status)
280
- end
281
- let(:can_create_version) { true }
282
- let(:version_link) { instance_double("PactBroker::Client::Hal::Link", put: version_resource) }
283
- let(:version_resource) { instance_double("PactBroker::Client::Hal::Entity") }
284
- let(:version_creation_response_status) { 201 }
285
-
286
- before do
287
- allow(index_resource).to receive(:_link).and_return(version_link)
288
- end
289
-
290
- context "when there is a branch, build_url or tags specified" do
291
- let(:tags) { ["dev"] }
292
- let(:branch) { ["main"] }
293
- let(:build_url) { "build_url" }
294
-
295
- it "creates a version with the branch, build_url and tags" do
296
- expect(index_resource).to receive(:_link)
297
- expect(version_link).to receive(:expand).with(pacticipant: "Consumer", version: "1.2.3")
298
- expect(version_link).to receive(:put).with(branch: branch, buildUrl: build_url)
299
- subject.call
300
- end
301
-
302
- context "when there is a branch but no tags" do
303
- let(:tags) { [] }
304
-
305
- it "does not set the tags, as this would overwrite the existing ones - not sure about this implementation" do
306
- expect(version_link).to receive(:put).with(branch: branch, buildUrl: build_url)
307
- subject.call
308
- end
309
- end
310
-
311
- context "when the version response status is 201" do
312
- it "puts a message indicating the version was created" do
313
- expect($stdout).to receive(:puts).with(/Created/)
314
- subject.call
315
- end
316
- end
317
-
318
- context "when the version response status is 200" do
319
- let(:version_creation_response_status) { 200 }
320
-
321
- it "puts a message indicating the version was replaced" do
322
- expect($stdout).to receive(:puts).with(/Replaced/)
323
- subject.call
324
- end
325
- end
326
- end
327
-
328
- context "when there is no branch, tags or build_url specified" do
329
- before do
330
- allow(Retry).to receive(:while_error) { |&block| block.call }
331
- end
332
- let(:tags) { [] }
333
- let(:branch) { nil }
334
- let(:build_url) { nil }
335
-
336
- it "does not create a version resource" do
337
- expect(index_resource).to_not receive(:_link)
338
- subject.call
339
- end
266
+ it "logs a warning" do
267
+ expect($stdout).to receive(:puts).with(/WARN: This version/)
268
+ subject.call
340
269
  end
341
270
  end
342
271
  end
@@ -186,112 +186,6 @@
186
186
  }
187
187
  }
188
188
  },
189
- {
190
- "description": "a request for the index resource",
191
- "providerState": "the pb:pacticipant-version relation exists in the index resource",
192
- "request": {
193
- "method": "get",
194
- "path": "/",
195
- "headers": {
196
- "Accept": "application/hal+json"
197
- }
198
- },
199
- "response": {
200
- "status": 200,
201
- "headers": {
202
- "Content-Type": "application/hal+json;charset=utf-8"
203
- },
204
- "body": {
205
- "_links": {
206
- "pb:pacticipant-version": {
207
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
208
- }
209
- }
210
- },
211
- "matchingRules": {
212
- "$.body._links.pb:pacticipant-version.href": {
213
- "match": "regex",
214
- "regex": "http:\\/\\/.*{pacticipant}.*{version}"
215
- }
216
- }
217
- }
218
- },
219
- {
220
- "description": "a request to create a pacticipant version",
221
- "providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist",
222
- "request": {
223
- "method": "put",
224
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
225
- "headers": {
226
- "Content-Type": "application/json",
227
- "Accept": "application/hal+json"
228
- },
229
- "body": {
230
- "branch": "main",
231
- "buildUrl": "http://my-ci/builds/1"
232
- }
233
- },
234
- "response": {
235
- "status": 201,
236
- "headers": {
237
- "Content-Type": "application/hal+json;charset=utf-8"
238
- },
239
- "body": {
240
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
241
- "branch": "main",
242
- "buildUrl": "http://my-ci/builds/1",
243
- "_links": {
244
- "self": {
245
- "href": "http://localhost:1234/some-url"
246
- }
247
- }
248
- },
249
- "matchingRules": {
250
- "$.body._links.self.href": {
251
- "match": "regex",
252
- "regex": "http:\\/\\/.*"
253
- }
254
- }
255
- }
256
- },
257
- {
258
- "description": "a request to create a pacticipant version",
259
- "providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist",
260
- "request": {
261
- "method": "put",
262
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
263
- "headers": {
264
- "Content-Type": "application/json",
265
- "Accept": "application/hal+json"
266
- },
267
- "body": {
268
- "branch": "main",
269
- "buildUrl": "http://my-ci/builds/1"
270
- }
271
- },
272
- "response": {
273
- "status": 200,
274
- "headers": {
275
- "Content-Type": "application/hal+json;charset=utf-8"
276
- },
277
- "body": {
278
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
279
- "branch": "main",
280
- "buildUrl": "http://my-ci/builds/1",
281
- "_links": {
282
- "self": {
283
- "href": "http://localhost:1234/some-url"
284
- }
285
- }
286
- },
287
- "matchingRules": {
288
- "$.body._links.self.href": {
289
- "match": "regex",
290
- "regex": "http:\\/\\/.*"
291
- }
292
- }
293
- }
294
- },
295
189
  {
296
190
  "description": "a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5",
297
191
  "providerState": "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",
@@ -1638,6 +1532,112 @@
1638
1532
  }
1639
1533
  }
1640
1534
  },
1535
+ {
1536
+ "description": "a request for the index resource",
1537
+ "providerState": "the pb:publish-contracts relations exists in the index resource",
1538
+ "request": {
1539
+ "method": "GET",
1540
+ "path": "/",
1541
+ "headers": {
1542
+ "Accept": "application/hal+json"
1543
+ }
1544
+ },
1545
+ "response": {
1546
+ "status": 200,
1547
+ "headers": {
1548
+ "Content-Type": "application/hal+json;charset=utf-8"
1549
+ },
1550
+ "body": {
1551
+ "_links": {
1552
+ "pb:publish-contracts": {
1553
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
1554
+ }
1555
+ }
1556
+ },
1557
+ "matchingRules": {
1558
+ "$.body._links.pb:publish-contracts.href": {
1559
+ "match": "regex",
1560
+ "regex": "http:\\/\\/.*"
1561
+ }
1562
+ }
1563
+ }
1564
+ },
1565
+ {
1566
+ "description": "a request to publish contracts",
1567
+ "request": {
1568
+ "method": "POST",
1569
+ "path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
1570
+ "headers": {
1571
+ "Content-Type": "application/json",
1572
+ "Accept": "application/hal+json"
1573
+ },
1574
+ "body": {
1575
+ "pacticipantName": "Foo",
1576
+ "pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1577
+ "branch": "main",
1578
+ "tags": [
1579
+ "dev"
1580
+ ],
1581
+ "buildUrl": "http://build",
1582
+ "contracts": [
1583
+ {
1584
+ "consumerName": "Foo",
1585
+ "providerName": "Bar",
1586
+ "specification": "pact",
1587
+ "contentType": "application/json",
1588
+ "content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
1589
+ "onConflict": "merge"
1590
+ }
1591
+ ]
1592
+ }
1593
+ },
1594
+ "response": {
1595
+ "status": 200,
1596
+ "headers": {
1597
+ "Content-Type": "application/hal+json;charset=utf-8"
1598
+ },
1599
+ "body": {
1600
+ "_embedded": {
1601
+ "pacticipant": {
1602
+ "name": "Foo"
1603
+ },
1604
+ "version": {
1605
+ "number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1606
+ "buildUrl": "http://build"
1607
+ }
1608
+ },
1609
+ "logs": [
1610
+ {
1611
+ "level": "info",
1612
+ "message": "some message"
1613
+ }
1614
+ ],
1615
+ "_links": {
1616
+ "pb:pacticipant-version-tags": [
1617
+ {
1618
+ "name": "dev"
1619
+ }
1620
+ ],
1621
+ "pb:contracts": [
1622
+ {
1623
+ "href": "http://some-pact"
1624
+ }
1625
+ ]
1626
+ }
1627
+ },
1628
+ "matchingRules": {
1629
+ "$.body.logs": {
1630
+ "min": 1
1631
+ },
1632
+ "$.body.logs[*].*": {
1633
+ "match": "type"
1634
+ },
1635
+ "$.body._links.pb:contracts[0].href": {
1636
+ "match": "type"
1637
+ }
1638
+ }
1639
+ }
1640
+ },
1641
1641
  {
1642
1642
  "description": "a request for the index resource",
1643
1643
  "providerState": "the pb:pacticipant-version and pb:environments relations exist in the index resource",
@@ -0,0 +1,16 @@
1
+ require "pact_broker/client/cli/broker"
2
+
3
+ RSpec.describe "the README" do
4
+ NOT_DOCUMENTED = ["version"]
5
+ COMMANDS = PactBroker::Client::CLI::Broker
6
+ .commands
7
+ .values
8
+ .collect(&:usage).collect { | usage | usage.split(" ").first } - NOT_DOCUMENTED
9
+ README = File.read("README.md")
10
+
11
+ COMMANDS.each do | command |
12
+ it "includes the documentation for #{command}" do
13
+ expect(README.include?("\n#### " + command)).to be_truthy
14
+ end
15
+ end
16
+ end
@@ -1,9 +1,7 @@
1
1
  require 'pact_broker/client/publish_pacts'
2
2
  require 'service_providers/pact_helper'
3
3
 
4
- publish_contracts_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("publish_contracts")
5
-
6
- RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feature_on do
4
+ RSpec.describe "publishing contracts", pact: true do
7
5
  before do
8
6
  allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
9
7
  allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
@@ -27,7 +25,7 @@ RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feat
27
25
  end
28
26
  let(:pact_file_path_1) { "spec/fixtures/foo-bar.json" }
29
27
  let(:pact_file_paths) { [pact_file_path_1] }
30
- let(:options) { {} }
28
+ let(:options) { { merge: true } }
31
29
  let(:pact_broker_client_options) { {} }
32
30
  let(:expected_content) { Base64.strict_encode64(JSON.parse(File.read(pact_file_path_1)).to_json) }
33
31
  let(:request_body) do
@@ -44,8 +42,7 @@ RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feat
44
42
  specification: "pact",
45
43
  contentType: "application/json",
46
44
  content: expected_content,
47
- writeMode: "overwrite",
48
- onConflict: "overwrite"
45
+ onConflict: "merge"
49
46
  }
50
47
  ]
51
48
  }