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 +5 -5
- data/CHANGELOG.md +7 -1
- data/lib/routemaster/api_client.rb +15 -11
- data/lib/routemaster/drain.rb +1 -1
- data/spec/routemaster/api_client_spec.rb +52 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0520ca5a0cdb1daad87055a37684ddf6bc80477
|
4
|
+
data.tar.gz: 8cd339befc65768cb048fedd8484fde9db05e8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc439ada70fc173308616b83490fea38d3c2705372fc29705aa9c3ae36b1b0bb309f73a64766a86e71e65d66b93b43b01b5bfe10b92101f9e749f48c604675b3
|
7
|
+
data.tar.gz: f500448852c281cf3098e5eb6a3bc413be90d26aea533fedb19f99574e274027e81be48bf2b07064364fa8b939b0703018ea44116027bfd0260c9d3c56e1c1fb
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
84
|
-
|
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)
|
data/lib/routemaster/drain.rb
CHANGED
@@ -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.
|
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-
|
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.
|
289
|
+
rubygems_version: 2.6.11
|
290
290
|
signing_key:
|
291
291
|
specification_version: 4
|
292
292
|
summary: Event receiver for the Routemaster bus
|