pact_broker-client 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7adaed58f0613b3153fe1aef45dec8b038903dba
4
- data.tar.gz: 59dd62e52015d518688a7a568e0297855edf40e0
3
+ metadata.gz: cd260ac11fff621cf61a0ac7ca6a7afd8c6e2628
4
+ data.tar.gz: 6618227846bb37655c20905d2a499b5d4127d35b
5
5
  SHA512:
6
- metadata.gz: 1b7e4b86f15221c2864b8bb7261ce005546dc3dfee965b03b9f30f25794d9c56de7c498614817aa4e5aded1c1f233ab73d1d011970e345d58fb04d792fc95fa6
7
- data.tar.gz: 86185d962b3b4ea670cf7e9776f0b5297d0c9889ff7161099485ebb18e5eabb09622a3bb7a5cab9650f5a24201772352b56b009cb49a182417c2320cc3b7c2a2
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
@@ -8,6 +8,7 @@
8
8
  3. Add files to git
9
9
 
10
10
  $ git add CHANGELOG.md lib/pact_broker/client/version.rb
11
+ $ git commit -m "Releasing version X.Y.Z"
11
12
 
12
13
  3. Release:
13
14
 
@@ -75,4 +75,4 @@ module PactBroker
75
75
 
76
76
  end
77
77
  end
78
- end
78
+ end
@@ -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
- response = self.class.put(url, body: pact_string, headers: default_put_headers)
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
- pact_broker_client_options = pact_broker_basic_auth ? {basic_auth: pact_broker_basic_auth} :{}
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
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.0.3'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  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
- before do
40
- pact_broker.
41
- given("the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0").
42
- upon_receiving("a request to publish a pact").
43
- with(
44
- method: :put,
45
- path: '/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0',
46
- headers: default_request_headers,
47
- body: pact_hash ).
48
- will_respond_with(
49
- headers: pact_broker_response_headers,
50
- status: 200,
51
- body: {
52
- _links: {
53
- :'pb:latest-pact-version' => {
54
- href: location
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
- end
60
- it "returns true" do
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
- expect(pact_broker_client.pacticipants.versions.pacts.publish(options)).to be_truthy
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(base_url: 'http://localhost:1234') }
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.3
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-06-27 00:00:00.000000000 Z
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
- - ".gitignore"
133
- - ".rspec"
134
- - ".travis.yml"
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.5.1
196
+ rubygems_version: 2.0.14
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: See description