lhc 6.3.0 → 6.3.1
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/lib/lhc/request.rb +7 -1
- data/lib/lhc/version.rb +1 -1
- data/spec/request/ignore_errors_spec.rb +35 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df32b734a941e2e400a2f41960b512146e90d5f4
|
4
|
+
data.tar.gz: cb8da5bda727e9559996c51d470efc5c3dcfb5b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 852ce45fb78bfe61eac47f742fd64ba660297bb2d7b32e1d534dd7b23ea949a11b919e99d1b60d153878c01914f5079ea10b802cda504d1aa2d5407957cb38eb
|
7
|
+
data.tar.gz: eecf72175a37b139a8a4b74682196384898427d18a469a043341701b49cc70f4844c2746dae1493b1913e562036dfd20be2cb6fb578d95145395fe3733a88cf0
|
data/lib/lhc/request.rb
CHANGED
@@ -102,11 +102,17 @@ class LHC::Request
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def handle_error(response)
|
105
|
-
return if
|
105
|
+
return if ignore_error?
|
106
106
|
throw_error(response) unless error_handler
|
107
107
|
response.body_replacement = error_handler.call(response)
|
108
108
|
end
|
109
109
|
|
110
|
+
def ignore_error?
|
111
|
+
errors_ignored.detect do |ignored_error|
|
112
|
+
error <= ignored_error
|
113
|
+
end.present?
|
114
|
+
end
|
115
|
+
|
110
116
|
def error
|
111
117
|
@error ||= LHC::Error.find(response)
|
112
118
|
end
|
data/lib/lhc/version.rb
CHANGED
@@ -1,13 +1,41 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHC::Request do
|
4
|
-
context '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
expect
|
10
|
-
|
4
|
+
context 'ignoring LHC::NotFound' do
|
5
|
+
subject { LHC.get('http://local.ch', ignored_errors: [LHC::NotFound]) }
|
6
|
+
before { stub_request(:get, 'http://local.ch').to_return(status: 404) }
|
7
|
+
|
8
|
+
it 'does not raise an error' do
|
9
|
+
expect { subject }.not_to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'body is nil' do
|
13
|
+
expect(subject.body).to eq nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'data is nil' do
|
17
|
+
expect(subject.data).to eq nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'does raise an error for 500' do
|
21
|
+
stub_request(:get, 'http://local.ch').to_return(status: 500)
|
22
|
+
expect { subject }.to raise_error LHC::InternalServerError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'inheritance when ignoring errors' do
|
27
|
+
before { stub_request(:get, 'http://local.ch').to_return(status: 404) }
|
28
|
+
|
29
|
+
it "does not raise an error when it's a subclass of the ignored error" do
|
30
|
+
expect {
|
31
|
+
LHC.get('http://local.ch', ignored_errors: [LHC::Error])
|
32
|
+
}.not_to raise_error
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does raise an error if it's not a subclass of the ignored error" do
|
36
|
+
expect {
|
37
|
+
LHC.get('http://local.ch', ignored_errors: [ArgumentError])
|
38
|
+
}.to raise_error(LHC::NotFound)
|
11
39
|
end
|
12
40
|
end
|
13
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.3.
|
4
|
+
version: 6.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhc/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -321,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
321
|
requirements:
|
322
322
|
- Ruby >= 2.0.0
|
323
323
|
rubyforge_project:
|
324
|
-
rubygems_version: 2.6.
|
324
|
+
rubygems_version: 2.6.8
|
325
325
|
signing_key:
|
326
326
|
specification_version: 4
|
327
327
|
summary: LocalHttpClient
|