tanga_services 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixtures/vcr_cassettes/422_request.yml +50 -0
- data/lib/tanga_services/http.rb +6 -0
- data/lib/tanga_services/version.rb +1 -1
- data/spec/http_spec.rb +11 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f103cf697c844cbc90daa7b495ef20e55ff19ee
|
4
|
+
data.tar.gz: 3238b1781e6966ee8e53caf5c393a18fe7cc1fcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4901884cb3860fbb78fd5ce9006967e493d17278a0fc38ed1426e1994727583a2832521bef037c83b7643d9b3ba0715c313edf414aefc7a725d579fe03dcf4b3
|
7
|
+
data.tar.gz: 012305de0fbd3f2b37f9b6dfa4aa6d5b07192781d4e133bef568991e1e3ffc3c31d10e670f33b924b45a5c065549e94f9ab2a3ccac23aebff38241e71f9643f7
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://httpbin.org/status/418
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 418
|
19
|
+
message: I'M A TEAPOT
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Thu, 07 Jul 2016 00:44:29 GMT
|
25
|
+
Content-Length:
|
26
|
+
- '135'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*"
|
31
|
+
X-More-Info:
|
32
|
+
- http://tools.ietf.org/html/rfc2324
|
33
|
+
Access-Control-Allow-Credentials:
|
34
|
+
- 'true'
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: |2
|
38
|
+
|
39
|
+
-=[ teapot ]=-
|
40
|
+
|
41
|
+
_...._
|
42
|
+
.' _ _ `.
|
43
|
+
| ."` ^ `". _,
|
44
|
+
\_;`"---"`|//
|
45
|
+
| ;/
|
46
|
+
\_ _/
|
47
|
+
`"""`
|
48
|
+
http_version:
|
49
|
+
recorded_at: Thu, 07 Jul 2016 00:44:29 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
data/lib/tanga_services/http.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'http/exceptions'
|
3
3
|
require 'json'
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_support/core_ext'
|
4
6
|
|
5
7
|
module TangaServices
|
6
8
|
class HTTP
|
@@ -8,6 +10,10 @@ module TangaServices
|
|
8
10
|
def to_s
|
9
11
|
cause.to_s
|
10
12
|
end
|
13
|
+
|
14
|
+
def code
|
15
|
+
cause.try(:response).code
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
%i( get put delete post ).each do |method|
|
data/spec/http_spec.rb
CHANGED
@@ -18,4 +18,15 @@ describe TS::HTTP do
|
|
18
18
|
end.to raise_error(described_class::Exception, /unexpected token/)
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
it 'puts response code on invalid requests' do
|
23
|
+
VCR.use_cassette('422 request') do
|
24
|
+
begin
|
25
|
+
described_class.get('https://httpbin.org/status/418')
|
26
|
+
fail 'i should not get here'
|
27
|
+
rescue => e
|
28
|
+
expect(e.code).to be == 418
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanga_services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Van Dyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- bin/rake
|
174
174
|
- bin/rspec
|
175
175
|
- bin/safe_yaml
|
176
|
+
- fixtures/vcr_cassettes/422_request.yml
|
176
177
|
- fixtures/vcr_cassettes/invalid_json.yml
|
177
178
|
- lib/tanga_services.rb
|
178
179
|
- lib/tanga_services/http.rb
|