restful_resource 2.0.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e1eacf50c2ea555b6163b0d5a788f1460dc26f4
4
- data.tar.gz: c04d86771984bd9ccd61e67bfa38cdc49c9d2fd8
3
+ metadata.gz: 82a879953f0ea77b78d0d10e389f71c52b871478
4
+ data.tar.gz: 58780ad094d558ac4fcc2a132c3df4405449b252
5
5
  SHA512:
6
- metadata.gz: 450a24de450adc7b8c27d3ff5f91c2c9c9a3cc04d61a4ac5bdd2eae71df2dcec28bfcd359091231e841f9911726fbca8c2b15d45c9b5752a11173a6867f824ce
7
- data.tar.gz: e79f1804f0469e64d5f2c78ed0394179fea08ae869fabc4109af62d8e762472956041f76da9d547be3da9b7703217765597f9f8b412228efa2b3cb472b21479c
6
+ metadata.gz: 5a7514ee216cd7f0d65844ce0f2e40f545792b61c0272b5249a089b4cb2c8564a01b83fcedb0df47e197ecd7d228957d615477c482921e42c4936ca0c51bfac1
7
+ data.tar.gz: 2e71dc51a9751ae363e9aa840f513196d704fcda064133a5ba86eac3fc64fcd7b1ce9abe8c968d46fb0a73e5a53ae78e3f8f8ff15dbc5adec5203e25f1adf6ce
@@ -36,6 +36,12 @@ module RestfulResource
36
36
  end
37
37
  end
38
38
 
39
+ class BadGateway < RetryableError
40
+ def message
41
+ "HTTP 502: Bad gateway"
42
+ end
43
+ end
44
+
39
45
  class ServiceUnavailable < RetryableError
40
46
  def message
41
47
  "HTTP 503: Service unavailable"
@@ -154,6 +160,7 @@ module RestfulResource
154
160
  case response[:status]
155
161
  when 404 then raise HttpClient::ResourceNotFound.new(request, response)
156
162
  when 422 then raise HttpClient::UnprocessableEntity.new(request, response)
163
+ when 502 then raise HttpClient::BadGateway.new(request, response)
157
164
  when 503 then raise HttpClient::ServiceUnavailable.new(request, response)
158
165
  else raise HttpClient::OtherHttpError.new(request, response)
159
166
  end
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -73,6 +73,22 @@ RSpec.describe RestfulResource::HttpClient do
73
73
  expect { http_client(connection).post('http://httpbin.org/status/422') }.to raise_error(RestfulResource::HttpClient::UnprocessableEntity)
74
74
  end
75
75
 
76
+ it 'put should raise error 502' do
77
+ connection = faraday_connection do |stubs|
78
+ stubs.put('http://httpbin.org/status/502') { |env| [502, {}, nil] }
79
+ end
80
+
81
+ expect { http_client(connection).put('http://httpbin.org/status/502') }.to raise_error(RestfulResource::HttpClient::BadGateway)
82
+ end
83
+
84
+ it 'post should raise error 502' do
85
+ connection = faraday_connection do |stubs|
86
+ stubs.post('http://httpbin.org/status/502') { |env| [502, {}, nil] }
87
+ end
88
+
89
+ expect { http_client(connection).post('http://httpbin.org/status/502') }.to raise_error(RestfulResource::HttpClient::BadGateway)
90
+ end
91
+
76
92
  it 'put should raise error 503' do
77
93
  connection = faraday_connection do |stubs|
78
94
  stubs.put('http://httpbin.org/status/503') { |env| [503, {}, nil] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro