oas 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -2
- data/lib/oas/client.rb +10 -0
- data/lib/oas/error.rb +11 -6
- data/lib/oas/version.rb +1 -1
- data/test/test_client.rb +40 -0
- 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: ac2086e9726bb05fa49002a5dfd5899a552aabf6
|
4
|
+
data.tar.gz: b87c2d1039175bab38ee843d459332fd91bdd43e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e755a03cec41cfb18d8ac554cc46dfa7cd1287bd3d96ed77be5772676846807486b476eafb5f5356383b2c7c77bdf411055dfd605be6bc87a83f8af312bad38f
|
7
|
+
data.tar.gz: 214c15764c43b4de01bff7f20d6241ba08be10dedb5ed9f7452c9f8705fb9d4e1a5e730e1a546aa1b0c7417ecea92fb84c881e65ddf966302f85f38290902fc0
|
data/.travis.yml
CHANGED
@@ -1,9 +1,22 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
1
4
|
language: ruby
|
2
5
|
rvm:
|
3
6
|
- 1.9.2
|
4
7
|
- 1.9.3
|
8
|
+
- 2.0.0
|
9
|
+
- 2.1
|
5
10
|
- jruby-19mode
|
6
|
-
-
|
11
|
+
- jruby-head
|
12
|
+
- rbx-2
|
13
|
+
- ruby-head
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: jruby-head
|
17
|
+
- rvm: rbx-2
|
18
|
+
- rvm: ruby-head
|
19
|
+
fast_finish: true
|
7
20
|
notifications:
|
8
21
|
email:
|
9
|
-
- dev@realmediadigital.com
|
22
|
+
- dev@realmediadigital.com
|
data/lib/oas/client.rb
CHANGED
@@ -39,8 +39,18 @@ module OAS
|
|
39
39
|
|
40
40
|
def _raise_http_error!(e)
|
41
41
|
case e.http.code
|
42
|
+
when 400
|
43
|
+
klass = OAS::Error::HTTP::BadRequest
|
44
|
+
when 401
|
45
|
+
klass = OAS::Error::HTTP::Unauthorized
|
42
46
|
when 403
|
43
47
|
klass = OAS::Error::HTTP::Forbidden
|
48
|
+
when 404
|
49
|
+
klass = OAS::Error::HTTP::NotFound
|
50
|
+
when 422
|
51
|
+
klass = OAS::Error::HTTP::UnprocessableEntity
|
52
|
+
when 429
|
53
|
+
klass = OAS::Error::HTTP::TooManyRequests
|
44
54
|
when 500
|
45
55
|
klass = OAS::Error::HTTP::InternalServerError
|
46
56
|
when 502
|
data/lib/oas/error.rb
CHANGED
@@ -9,11 +9,16 @@ module OAS
|
|
9
9
|
@headers = headers
|
10
10
|
@body = body
|
11
11
|
end
|
12
|
-
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
BadRequest = Class.new(self)
|
14
|
+
Unauthorized = Class.new(self)
|
15
|
+
Forbidden = Class.new(self)
|
16
|
+
NotFound = Class.new(self)
|
17
|
+
UnprocessableEntity = Class.new(self)
|
18
|
+
TooManyRequests = Class.new(self)
|
19
|
+
BadGateway = Class.new(self)
|
20
|
+
GatewayTimeout = Class.new(self)
|
21
|
+
InternalServerError = Class.new(self)
|
22
|
+
ServiceUnavailable = Class.new(self)
|
23
|
+
end
|
19
24
|
end
|
data/lib/oas/version.rb
CHANGED
data/test/test_client.rb
CHANGED
@@ -48,6 +48,22 @@ class TestClient < MiniTest::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def test_raise_http_badrequest_error
|
52
|
+
stub_request(:post, @client.endpoint.to_s).to_return(:status => 400)
|
53
|
+
|
54
|
+
assert_raises OAS::Error::HTTP::BadRequest do
|
55
|
+
@client.execute(@request)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_raise_http_unauthorized_error
|
60
|
+
stub_request(:post, @client.endpoint.to_s).to_return(:status => 401)
|
61
|
+
|
62
|
+
assert_raises OAS::Error::HTTP::Unauthorized do
|
63
|
+
@client.execute(@request)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
51
67
|
def test_raise_http_forbidden_error
|
52
68
|
stub_request(:post, @client.endpoint.to_s).to_return(:status => 403)
|
53
69
|
|
@@ -56,6 +72,30 @@ class TestClient < MiniTest::Unit::TestCase
|
|
56
72
|
end
|
57
73
|
end
|
58
74
|
|
75
|
+
def test_raise_http_notfound_error
|
76
|
+
stub_request(:post, @client.endpoint.to_s).to_return(:status => 404)
|
77
|
+
|
78
|
+
assert_raises OAS::Error::HTTP::NotFound do
|
79
|
+
@client.execute(@request)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_raise_http_unprocessable_entity_error
|
84
|
+
stub_request(:post, @client.endpoint.to_s).to_return(:status => 422)
|
85
|
+
|
86
|
+
assert_raises OAS::Error::HTTP::UnprocessableEntity do
|
87
|
+
@client.execute(@request)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_raise_http_too_many_requests_error
|
92
|
+
stub_request(:post, @client.endpoint.to_s).to_return(:status => 429)
|
93
|
+
|
94
|
+
assert_raises OAS::Error::HTTP::TooManyRequests do
|
95
|
+
@client.execute(@request)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
59
99
|
def test_raise_http_internal_server_error_error
|
60
100
|
stub_request(:post, @client.endpoint.to_s).to_return(:status => 500)
|
61
101
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Caruso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|