lhc 6.3.1 → 6.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/lhc/request.rb +9 -3
- data/lib/lhc/response.rb +1 -0
- data/lib/lhc/version.rb +1 -1
- data/spec/request/ignore_errors_spec.rb +10 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80f4055f440bc7f36343e387c27cbe4526e2969e
|
4
|
+
data.tar.gz: 50b0cb3ae16bc7cc9098a2e9069d03d91314304b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e71ceba6f6f43b0112aecf6d8b92470628cbdf29e855c237a8ec26a2cf22f13ed24add47230268daf4e74a16574fb4e5b23f72744e7ef36bece5b1945d953e7a
|
7
|
+
data.tar.gz: 6f1d15f6cb8b7aff8cfc64553d8366a951f4d8bd579e57c182003be2011955bf8da967de2fb1e9fc0af8c4648e7c285928f2d8a5a7a6ba4fc19b76245bbd019a
|
data/README.md
CHANGED
data/lib/lhc/request.rb
CHANGED
@@ -39,6 +39,10 @@ class LHC::Request
|
|
39
39
|
raw.options.fetch(:params, nil) || raw.options[:params] = {}
|
40
40
|
end
|
41
41
|
|
42
|
+
def error_ignored?
|
43
|
+
ignore_error?
|
44
|
+
end
|
45
|
+
|
42
46
|
private
|
43
47
|
|
44
48
|
attr_accessor :iprocessor
|
@@ -108,9 +112,11 @@ class LHC::Request
|
|
108
112
|
end
|
109
113
|
|
110
114
|
def ignore_error?
|
111
|
-
|
112
|
-
|
113
|
-
|
115
|
+
@ignore_error ||= begin
|
116
|
+
errors_ignored.detect do |ignored_error|
|
117
|
+
error <= ignored_error
|
118
|
+
end.present?
|
119
|
+
end
|
114
120
|
end
|
115
121
|
|
116
122
|
def error
|
data/lib/lhc/response.rb
CHANGED
@@ -9,6 +9,7 @@ class LHC::Response
|
|
9
9
|
attr_reader :from_cache
|
10
10
|
|
11
11
|
delegate :effective_url, :code, :headers, :options, :mock, :success?, to: :raw
|
12
|
+
delegate :error_ignored?, to: :request
|
12
13
|
alias from_cache? from_cache
|
13
14
|
|
14
15
|
# A response is initalized with the underlying raw response (typhoeus in our case)
|
data/lib/lhc/version.rb
CHANGED
@@ -2,24 +2,29 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe LHC::Request do
|
4
4
|
context 'ignoring LHC::NotFound' do
|
5
|
-
|
5
|
+
let(:response) { LHC.get('http://local.ch', ignored_errors: [LHC::NotFound]) }
|
6
6
|
before { stub_request(:get, 'http://local.ch').to_return(status: 404) }
|
7
7
|
|
8
8
|
it 'does not raise an error' do
|
9
|
-
expect {
|
9
|
+
expect { response }.not_to raise_error
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'body is nil' do
|
13
|
-
expect(
|
13
|
+
expect(response.body).to eq nil
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'data is nil' do
|
17
|
-
expect(
|
17
|
+
expect(response.data).to eq nil
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'does raise an error for 500' do
|
21
21
|
stub_request(:get, 'http://local.ch').to_return(status: 500)
|
22
|
-
expect {
|
22
|
+
expect { response }.to raise_error LHC::InternalServerError
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'provides the information if the error was ignored' do
|
26
|
+
expect(response.error_ignored?).to eq true
|
27
|
+
expect(response.request.error_ignored?).to eq true
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
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.
|
4
|
+
version: 6.4.0
|
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-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|