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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 233674473f6bee30abefd2e5e2036c9d1daa2d91
4
- data.tar.gz: f4daee2ade3161167fdd8150da45b900bb960cf3
3
+ metadata.gz: 4f103cf697c844cbc90daa7b495ef20e55ff19ee
4
+ data.tar.gz: 3238b1781e6966ee8e53caf5c393a18fe7cc1fcb
5
5
  SHA512:
6
- metadata.gz: a359f5d541570a1dd4de148ba08605440964ae6b2975627cb5c6d684dadaaa472e311020046818b7201c5b55262b359291c02ad8d2178de52b8282de732fea6b
7
- data.tar.gz: 9559b4e131bb9e3540a3e23d92cad15cb8c28fc5b4ce4be2c805aa737a504f954a75ff855c6c9a274597d320db1ca46b51a102d5b372619f4025958810ec9e2e
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
@@ -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|
@@ -1,3 +1,3 @@
1
1
  module TangaServices
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
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.12
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-01-09 00:00:00.000000000 Z
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