routemaster-drain 3.2.0 → 3.3.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
- SHA256:
3
- metadata.gz: 1ddda71d2b877bc368adcfb3d6f97d6c79916b8b2d72db9036d4bdf34ae7f5d8
4
- data.tar.gz: 2c3371a3ed8b1df43f743bbc3d9e715fc8ea63ea796042b922f564c13da45467
2
+ SHA1:
3
+ metadata.gz: a0520ca5a0cdb1daad87055a37684ddf6bc80477
4
+ data.tar.gz: 8cd339befc65768cb048fedd8484fde9db05e8e0
5
5
  SHA512:
6
- metadata.gz: a4034317d864f77c4b111f0837673fc3bc9b7f1cb3f93fa79aeff4170b2d80dcf9f6a3cc58072a5a6819791013612a04c59a34baee67b2380ac0a36dd66a8c52
7
- data.tar.gz: 51b7c394000cbe0efe657f53ea00b7d4d99063675796a78e8ee3f72e8708e18256311c93792bcd98875a022ac80bc29c20f6eaa034ae178ad6f6ef3196093a38
6
+ metadata.gz: fc439ada70fc173308616b83490fea38d3c2705372fc29705aa9c3ae36b1b0bb309f73a64766a86e71e65d66b93b43b01b5bfe10b92101f9e749f48c604675b3
7
+ data.tar.gz: f500448852c281cf3098e5eb6a3bc413be90d26aea533fedb19f99574e274027e81be48bf2b07064364fa8b939b0703018ea44116027bfd0260c9d3c56e1c1fb
data/CHANGELOG.md CHANGED
@@ -1,10 +1,16 @@
1
+ ### 3.3.0 (2017-11-16)
2
+
3
+ Features:
4
+
5
+ - Adds a PUT request to the APIClient
6
+
1
7
  ### 3.2.0 (2017-11-10)
2
8
 
3
9
  Features:
4
10
 
5
11
  - Adds a circuit breaker to GET requests (#66)
6
12
 
7
- ### 3.1.0 (2017-11-2)
13
+ ### 3.1.0 (2017-11-02)
8
14
 
9
15
  Features:
10
16
 
@@ -72,20 +72,16 @@ module Routemaster
72
72
  Responses::ResponsePromise.new { get(uri, options) }
73
73
  end
74
74
 
75
+ def patch(url, body: {}, headers: {})
76
+ patch_post_or_put(:patch, url, body, headers)
77
+ end
78
+
75
79
  def post(url, body: {}, headers: {})
76
- _wrapped_response _request(
77
- :post,
78
- url: url,
79
- body: body,
80
- headers: headers)
80
+ patch_post_or_put(:post, url, body, headers)
81
81
  end
82
82
 
83
- def patch(url, body: {}, headers: {})
84
- _wrapped_response _request(
85
- :patch,
86
- url: url,
87
- body: body,
88
- headers: headers)
83
+ def put(url, body: {}, headers: {})
84
+ patch_post_or_put(:put, url, body, headers)
89
85
  end
90
86
 
91
87
  def delete(url, headers: {})
@@ -98,6 +94,14 @@ module Routemaster
98
94
 
99
95
  private
100
96
 
97
+ def patch_post_or_put(type, url, body, headers)
98
+ _wrapped_response _request(
99
+ type,
100
+ url: url,
101
+ body: body,
102
+ headers: headers)
103
+ end
104
+
101
105
  def _assert_uri(url)
102
106
  return url if url.kind_of?(URI)
103
107
  URI.parse(url)
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  module Drain
3
- VERSION = '3.2.0'.freeze
3
+ VERSION = '3.3.0'.freeze
4
4
  end
5
5
  end
@@ -158,6 +158,58 @@ describe Routemaster::APIClient do
158
158
  it_behaves_like 'a wrappable response'
159
159
  end
160
160
 
161
+ describe '#put' do
162
+ let(:body) { { 'one' => 1, 'two' => 2 }.to_json }
163
+ subject { fetcher.put(url, body: body, headers: headers) }
164
+
165
+ context 'when request succeeds' do
166
+ before do
167
+ @put_req= stub_request(:put, /example\.com/).to_return(
168
+ status: 200,
169
+ body: { id: 132, type: 'widget' }.to_json,
170
+ headers: {
171
+ 'content-type' => 'application/json;v=1'
172
+ }
173
+ )
174
+ end
175
+
176
+ it 'PUT from the URL' do
177
+ subject
178
+ expect(@put_req).to have_been_requested
179
+ end
180
+
181
+ it_behaves_like 'a wrappable response'
182
+ end
183
+
184
+ context 'when request times out' do
185
+ subject do
186
+ begin
187
+ fetcher.put(url, body: body, headers: headers)
188
+ rescue Faraday::TimeoutError
189
+ end
190
+ end
191
+
192
+ before do
193
+ stub_request(:put, url).to_timeout
194
+ end
195
+
196
+ it 'tries the PUT request three times' do
197
+ subject
198
+ assert_requested(:put, url, body: body, times: 3)
199
+ end
200
+
201
+ context 'when retry attempt count is specified' do
202
+ let(:retry_attempts) { 4 }
203
+ let(:fetcher) { described_class.new(retry_attempts: retry_attempts) }
204
+
205
+ it "tries the PUT request '1 + retry-count' times" do
206
+ subject
207
+ assert_requested(:put, url, body: body, times: 1 + retry_attempts)
208
+ end
209
+ end
210
+ end
211
+ end
212
+
161
213
  describe '#patch' do
162
214
  let(:body) { { 'one' => 1, 'two' => 2 }.to_json }
163
215
  subject { fetcher.patch(url, body: body, headers: headers) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routemaster-drain
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -286,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  version: '0'
287
287
  requirements: []
288
288
  rubyforge_project:
289
- rubygems_version: 2.7.0
289
+ rubygems_version: 2.6.11
290
290
  signing_key:
291
291
  specification_version: 4
292
292
  summary: Event receiver for the Routemaster bus