lhc 6.3.0 → 6.3.1

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
2
  SHA1:
3
- metadata.gz: 503f2e88095de04d6f071fd2285459f106ff2f7d
4
- data.tar.gz: 1e7c8bd5c1878d11ce293208c43f7886714891bf
3
+ metadata.gz: df32b734a941e2e400a2f41960b512146e90d5f4
4
+ data.tar.gz: cb8da5bda727e9559996c51d470efc5c3dcfb5b0
5
5
  SHA512:
6
- metadata.gz: 0e8fbabecb039bfe29377cdd7ee30f52aea980d459918953f5df9b1e92b48c9e15ce15392122dc1dabb9934ca3fc8ac5fb44d2c6f64a1545996bebe24ca6d12e
7
- data.tar.gz: a21700e4b7979715066c2659bc492fee013dee54a0471427f6c6dac414c3ff94855bb1b289f3c6900d36714e7200b105e52ec1f46067aeb16909d6a837458d05
6
+ metadata.gz: 852ce45fb78bfe61eac47f742fd64ba660297bb2d7b32e1d534dd7b23ea949a11b919e99d1b60d153878c01914f5079ea10b802cda504d1aa2d5407957cb38eb
7
+ data.tar.gz: eecf72175a37b139a8a4b74682196384898427d18a469a043341701b49cc70f4844c2746dae1493b1913e562036dfd20be2cb6fb578d95145395fe3733a88cf0
@@ -102,11 +102,17 @@ class LHC::Request
102
102
  end
103
103
 
104
104
  def handle_error(response)
105
- return if errors_ignored.include?(error)
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
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= "6.3.0"
2
+ VERSION ||= "6.3.1"
3
3
  end
@@ -1,13 +1,41 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe LHC::Request do
4
- context 'ignore errors' do
5
- it 'raises errors for anything but 2XX response codes' do
6
- stub_request(:get, 'http://local.ch').to_return(status: 404)
7
- response = LHC.get('http://local.ch', ignored_errors: [LHC::NotFound])
8
- expect(response.body).to eq nil
9
- expect(response.data).to eq nil
10
- expect(response.success?).to eq false
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.0
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-15 00:00:00.000000000 Z
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.12
324
+ rubygems_version: 2.6.8
325
325
  signing_key:
326
326
  specification_version: 4
327
327
  summary: LocalHttpClient