pact_broker-client 1.0.3 → 1.1.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -0
- data/RELEASING.md +1 -0
- data/lib/pact_broker/client/base_client.rb +1 -1
- data/lib/pact_broker/client/pacts.rb +7 -1
- data/lib/pact_broker/client/tasks/publication_task.rb +4 -3
- data/lib/pact_broker/client/version.rb +1 -1
- data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +15 -1
- data/spec/pacts/pact_broker_client-pact_broker.json +35 -1
- data/spec/service_providers/pact_broker_client_publish_spec.rb +34 -21
- data/spec/support/shared_context.rb +3 -2
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd260ac11fff621cf61a0ac7ca6a7afd8c6e2628
|
4
|
+
data.tar.gz: 6618227846bb37655c20905d2a499b5d4127d35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b5f64103ed3a3b14c47021a50ae577330a40cec1469455d6ec888c53bca8867ab13fcb82f7270a2a8d1d32e0d81e99f41ebb1950ed82dea8c6edff3a905f63e
|
7
|
+
data.tar.gz: 3131f849daf5d09f8f3edd570d8e20751fb2be390412e480e1f69f88d1605c0fa2b8efdfad0673b0fb52f6e46042553a7aa3978198acd7fff57e3ca3544b1033
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
$ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
|
4
4
|
|
5
|
+
#### 1.1.0 (2016-08-19)
|
6
|
+
* b5ea1b3 - Add support for publishing pacts via patch request (Steve Pletcher, Fri Aug 5 11:16:18 2016 -0400)
|
7
|
+
|
5
8
|
#### 1.0.3 (2016-06-27)
|
6
9
|
|
7
10
|
* 04bd518 - Clarify that pact_broker-client will only work with ruby >= 2.0 (Sergei Matheson, Mon Jun 27 11:17:57 2016 +1000)
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ PactBroker::Client::PublicationTask.new do | task |
|
|
24
24
|
task.consumer_version = MyConsumer::VERSION
|
25
25
|
task.pact_broker_base_url = "http://pact-broker.my.org"
|
26
26
|
task.pact_broker_basic_auth = { username: 'basic_auth_user', password: 'basic_auth_pass'} #optional
|
27
|
+
task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists
|
27
28
|
end
|
28
29
|
```
|
29
30
|
|
data/RELEASING.md
CHANGED
@@ -11,7 +11,13 @@ module PactBroker
|
|
11
11
|
pact_string = options[:pact_json]
|
12
12
|
consumer_contract = ::Pact::ConsumerContract.from_json pact_string
|
13
13
|
url = save_consumer_contract_url consumer_contract, consumer_version
|
14
|
-
|
14
|
+
|
15
|
+
if @client_options[:write] == :merge
|
16
|
+
response = self.class.patch(url, body: pact_string, headers: default_patch_headers)
|
17
|
+
else
|
18
|
+
response = self.class.put(url, body: pact_string, headers: default_put_headers)
|
19
|
+
end
|
20
|
+
|
15
21
|
handle_response(response) do
|
16
22
|
latest_link = find_latest_link JSON.parse(response.body)
|
17
23
|
if latest_link.nil?
|
@@ -15,7 +15,7 @@ module PactBroker
|
|
15
15
|
module Client
|
16
16
|
class PublicationTask < ::Rake::TaskLib
|
17
17
|
|
18
|
-
attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :pact_broker_basic_auth
|
18
|
+
attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :write_method, :pact_broker_basic_auth
|
19
19
|
|
20
20
|
def initialize name = nil, &block
|
21
21
|
@name = name
|
@@ -32,7 +32,8 @@ module PactBroker
|
|
32
32
|
task task_name do
|
33
33
|
block.call(self)
|
34
34
|
require 'pact_broker/client/publish_pacts'
|
35
|
-
|
35
|
+
basic_auth_client_options = pact_broker_basic_auth ? {basic_auth: pact_broker_basic_auth} : {}
|
36
|
+
pact_broker_client_options = basic_auth_client_options.merge(write_method ? {write: write_method} : {})
|
36
37
|
success = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[pattern], consumer_version, pact_broker_client_options).call
|
37
38
|
raise "One or more pacts failed to be published" unless success
|
38
39
|
end
|
@@ -45,4 +46,4 @@ module PactBroker
|
|
45
46
|
|
46
47
|
end
|
47
48
|
end
|
48
|
-
end
|
49
|
+
end
|
@@ -44,6 +44,20 @@ module PactBroker::Client
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
describe "merge method configuration" do
|
48
|
+
before :all do
|
49
|
+
PactBroker::Client::PublicationTask.new(:merge) do | task |
|
50
|
+
task.consumer_version = '1.2.3'
|
51
|
+
task.write_method = :merge
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "invokes PublishPacts with the write method set" do
|
56
|
+
PactBroker::Client::PublishPacts.should_receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', {write: :merge}).and_return(publish_pacts)
|
57
|
+
publish_pacts.should_receive(:call).and_return(true)
|
58
|
+
Rake::Task['pact:publish:merge'].execute
|
59
|
+
end
|
60
|
+
end
|
47
61
|
|
48
62
|
describe "custom task" do
|
49
63
|
|
@@ -84,4 +98,4 @@ module PactBroker::Client
|
|
84
98
|
|
85
99
|
end
|
86
100
|
|
87
|
-
end
|
101
|
+
end
|
@@ -236,7 +236,41 @@
|
|
236
236
|
}
|
237
237
|
},
|
238
238
|
{
|
239
|
-
"description": "a request to publish a pact",
|
239
|
+
"description": "a request to publish a pact with method patch",
|
240
|
+
"provider_state": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
|
241
|
+
"request": {
|
242
|
+
"method": "patch",
|
243
|
+
"path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
|
244
|
+
"headers": {
|
245
|
+
"Content-Type": "application/json"
|
246
|
+
},
|
247
|
+
"body": {
|
248
|
+
"consumer": {
|
249
|
+
"name": "Condor"
|
250
|
+
},
|
251
|
+
"provider": {
|
252
|
+
"name": "Pricing Service"
|
253
|
+
},
|
254
|
+
"interactions": [
|
255
|
+
|
256
|
+
]
|
257
|
+
}
|
258
|
+
},
|
259
|
+
"response": {
|
260
|
+
"status": 200,
|
261
|
+
"headers": {
|
262
|
+
},
|
263
|
+
"body": {
|
264
|
+
"_links": {
|
265
|
+
"pb:latest-pact-version": {
|
266
|
+
"href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/latest"
|
267
|
+
}
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
},
|
272
|
+
{
|
273
|
+
"description": "a request to publish a pact with method put",
|
240
274
|
"provider_state": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
|
241
275
|
"request": {
|
242
276
|
"method": "put",
|
@@ -36,29 +36,42 @@ module PactBroker::Client
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context "when the provider, consumer, pact and version already exist in the pact-broker" do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
:
|
54
|
-
|
39
|
+
shared_examples "an already-existing pact" do |method|
|
40
|
+
before do
|
41
|
+
pact_broker.
|
42
|
+
given("the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0").
|
43
|
+
upon_receiving("a request to publish a pact with method #{method}").
|
44
|
+
with(
|
45
|
+
method: method,
|
46
|
+
path: '/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0',
|
47
|
+
headers: default_request_headers,
|
48
|
+
body: pact_hash ).
|
49
|
+
will_respond_with(
|
50
|
+
headers: pact_broker_response_headers,
|
51
|
+
status: 200,
|
52
|
+
body: {
|
53
|
+
_links: {
|
54
|
+
:'pb:latest-pact-version' => {
|
55
|
+
href: location
|
56
|
+
}
|
55
57
|
}
|
56
58
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns true" do
|
61
63
|
expect(pact_broker_client.pacticipants.versions.pacts.publish(options)).to be_truthy
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when the write method is set to merge" do
|
68
|
+
let(:client_config) { super().merge(client_options: {write: :merge}) }
|
69
|
+
|
70
|
+
it_behaves_like "an already-existing pact", :patch
|
71
|
+
end
|
72
|
+
|
73
|
+
context "when the write method is not set" do
|
74
|
+
it_behaves_like "an already-existing pact", :put
|
62
75
|
end
|
63
76
|
end
|
64
77
|
|
@@ -85,7 +98,7 @@ module PactBroker::Client
|
|
85
98
|
)
|
86
99
|
end
|
87
100
|
it "returns true" do
|
88
|
-
|
101
|
+
expect(pact_broker_client.pacticipants.versions.pacts.publish(options)).to be_truthy
|
89
102
|
end
|
90
103
|
end
|
91
104
|
|
@@ -3,7 +3,8 @@ shared_context "pact broker" do
|
|
3
3
|
let(:pact_hash) { {consumer: {name: 'Condor'}, provider: {name: 'Pricing Service'}, interactions: []} }
|
4
4
|
let(:consumer_contract) { Pact::ConsumerContract.from_hash pact_hash }
|
5
5
|
let(:pact_json) { pact_hash.to_json }
|
6
|
-
let(:pact_broker_client) { PactBroker::Client::PactBrokerClient.new(
|
6
|
+
let(:pact_broker_client) { PactBroker::Client::PactBrokerClient.new(client_config) }
|
7
|
+
let(:client_config) { { base_url: 'http://localhost:1234' } }
|
7
8
|
let(:consumer_version) { '1.3.0' }
|
8
9
|
let(:version) { '1.3.0' }
|
9
10
|
let(:pact_broker_version) { Pact::Term.new(:matcher => /\d+\.\d+\.\d+/, :generate => '1.0.0') }
|
@@ -12,4 +13,4 @@ shared_context "pact broker" do
|
|
12
13
|
let(:patch_request_headers) { { 'Content-Type' => 'application/json'} }
|
13
14
|
let(:get_request_headers) { { 'Accept' => 'application/json'} }
|
14
15
|
|
15
|
-
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bethany Skurrie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pact
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: httparty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: term-ansicolor
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 10.0.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 10.0.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: fakefs
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-fire
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: Publishes pacts to, and retrieves pacts from, the pact broker server.
|
@@ -129,9 +129,9 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
132
|
+
- .gitignore
|
133
|
+
- .rspec
|
134
|
+
- .travis.yml
|
135
135
|
- CHANGELOG.md
|
136
136
|
- Gemfile
|
137
137
|
- README.md
|
@@ -183,17 +183,17 @@ require_paths:
|
|
183
183
|
- lib
|
184
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- -
|
186
|
+
- - '>='
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '2.0'
|
189
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
|
-
- -
|
191
|
+
- - '>='
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
195
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.0.14
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: See description
|