http-exceptions 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/http-exceptions.gemspec +5 -5
- data/lib/http/exceptions.rb +1 -1
- data/lib/http/exceptions/version.rb +1 -1
- data/spec/http_exception_spec.rb +40 -16
- metadata +7 -7
- data/.rvmrc +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03bd2eec282320ea2757da660f823694333ec23d
|
4
|
+
data.tar.gz: aa793159eb0c1f53c1528a250f7272664e41f871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd355b76607a59d58bb287af11e062e0912ddb08cd0adca784ca96cc373bb0194a9ccfdbe768c66473becd39c1253d4246c1f267f10e4910e597b6b1090fb0dc
|
7
|
+
data.tar.gz: bbc6ecf77d7ec8913adafe9e7b19ae008d76f3a42f4cf0ee102670882361c2ed83e81dbe5ebeb3454721303f0217ce72886ae89b8e2908aeeb7af5a0a78ab324
|
data/http-exceptions.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'http/exceptions/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "http-exceptions"
|
8
8
|
spec.version = Http::Exceptions::VERSION
|
9
|
-
spec.authors = ["Simon Mathieu"]
|
10
|
-
spec.email = ["simon.math@gmail.com"]
|
11
|
-
spec.summary = %q{An easy way to rescue exceptions that might be thrown by your
|
12
|
-
spec.description = %q{An easy way to rescue exceptions that might be thrown by your
|
13
|
-
spec.homepage = ""
|
9
|
+
spec.authors = ["Simon Mathieu", "Russell Smith"]
|
10
|
+
spec.email = ["simon.math@gmail.com", "russ@rainforestqa.com"]
|
11
|
+
spec.summary = %q{An easy way to rescue exceptions that might be thrown by your HTTP library}
|
12
|
+
spec.description = %q{An easy way to rescue exceptions that might be thrown by your HTTP library}
|
13
|
+
spec.homepage = "https://github.com/rainforestapp/http-exceptions"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
data/lib/http/exceptions.rb
CHANGED
data/spec/http_exception_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Http::Exceptions do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:code) { 200 }
|
5
|
+
let(:response) { double(code: code, body: '') }
|
6
6
|
|
7
7
|
class TestException < RuntimeError
|
8
8
|
end
|
9
9
|
|
10
10
|
describe ".wrap_exception" do
|
11
|
-
let(:supported_exception_class)
|
11
|
+
let(:supported_exception_class) { Http::Exceptions::Configuration::DEFAULT_EXCEPTIONS_TO_CONVERT.first }
|
12
12
|
let(:unsupported_exception_class) { TestException }
|
13
13
|
|
14
14
|
context "when exception class is supported" do
|
@@ -47,30 +47,54 @@ describe Http::Exceptions do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe ".check_response!" do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
shared_examples 'invalid response' do |error_status_code|
|
51
|
+
context "when the response code is not a 200" do
|
52
|
+
let(:code) { error_status_code }
|
53
|
+
|
54
|
+
it "raises exception" do
|
55
|
+
expect do
|
56
|
+
described_class.check_response!(response)
|
57
|
+
end.to raise_error(Http::Exceptions::HttpException)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "the raised exception contains the response" do
|
62
|
+
begin
|
63
|
+
described_class.check_response!(response)
|
64
|
+
rescue Http::Exceptions::HttpException => e
|
65
|
+
expect(e.response).to eq(response)
|
66
|
+
end
|
67
|
+
end
|
54
68
|
end
|
55
69
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
70
|
+
shared_examples 'valid response' do |successful_status_code|
|
71
|
+
context "when the response code is a 200" do
|
72
|
+
let(:code) { successful_status_code }
|
73
|
+
|
74
|
+
it "returns the response" do
|
75
|
+
expect(described_class.check_response!(response)).to eq(response)
|
76
|
+
end
|
61
77
|
end
|
62
78
|
end
|
63
79
|
|
64
|
-
|
65
|
-
|
80
|
+
context "when the response code is an integer" do
|
81
|
+
it_behaves_like 'invalid response', 400
|
82
|
+
it_behaves_like 'valid response', 200
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when the response code is a string" do
|
86
|
+
it_behaves_like 'invalid response', '400'
|
87
|
+
it_behaves_like 'valid response', '200'
|
66
88
|
end
|
67
89
|
end
|
68
90
|
|
69
91
|
describe ".wrap_and_check" do
|
70
|
-
|
92
|
+
let(:code) { 400 }
|
93
|
+
|
94
|
+
it "raises an exception on a response with an error code" do
|
71
95
|
expect do
|
72
96
|
described_class.wrap_and_check do
|
73
|
-
|
97
|
+
response
|
74
98
|
end
|
75
99
|
end.to raise_error(Http::Exceptions::HttpException)
|
76
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-exceptions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Mathieu
|
8
|
+
- Russell Smith
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -38,16 +39,16 @@ dependencies:
|
|
38
39
|
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
|
-
description: An easy way to rescue exceptions that might be thrown by your
|
42
|
+
description: An easy way to rescue exceptions that might be thrown by your HTTP library
|
42
43
|
email:
|
43
44
|
- simon.math@gmail.com
|
45
|
+
- russ@rainforestqa.com
|
44
46
|
executables: []
|
45
47
|
extensions: []
|
46
48
|
extra_rdoc_files: []
|
47
49
|
files:
|
48
50
|
- ".gitignore"
|
49
51
|
- ".rspec"
|
50
|
-
- ".rvmrc"
|
51
52
|
- ".travis.yml"
|
52
53
|
- Gemfile
|
53
54
|
- LICENSE.txt
|
@@ -61,7 +62,7 @@ files:
|
|
61
62
|
- spec/http/exceptions/configuration_spec.rb
|
62
63
|
- spec/http_exception_spec.rb
|
63
64
|
- spec/spec_helper.rb
|
64
|
-
homepage:
|
65
|
+
homepage: https://github.com/rainforestapp/http-exceptions
|
65
66
|
licenses:
|
66
67
|
- MIT
|
67
68
|
metadata: {}
|
@@ -84,9 +85,8 @@ rubyforge_project:
|
|
84
85
|
rubygems_version: 2.5.1
|
85
86
|
signing_key:
|
86
87
|
specification_version: 4
|
87
|
-
summary: An easy way to rescue exceptions that might be thrown by your
|
88
|
+
summary: An easy way to rescue exceptions that might be thrown by your HTTP library
|
88
89
|
test_files:
|
89
90
|
- spec/http/exceptions/configuration_spec.rb
|
90
91
|
- spec/http_exception_spec.rb
|
91
92
|
- spec/spec_helper.rb
|
92
|
-
has_rdoc:
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 2.2.0@http-exceptions --create
|