esp_sdk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 520f29b68fe7bd73da0714e509b3d4841ef443ad
4
- data.tar.gz: 85afbc8f059b54faec9ae1255727ce1e66b83dfb
3
+ metadata.gz: bc0bc0f5a43edd2fe55e5a88ac0f85dc57e94b2e
4
+ data.tar.gz: 900c1b216c3701add2360f9a547b73ddc9ad1df3
5
5
  SHA512:
6
- metadata.gz: b6c9d523803902d5af24a808f6be7bd40da3b47b05f793ebcf938ca5e26207f4890c59ff8133d7849507cd8df7681b7f43d87587222f771ff8c7690c79cda23a
7
- data.tar.gz: 2c767ccffca788f67bc3913251675fd922b7701e9369488a59b57039aa523ef84ded6b3b9b03336e032e4a36071127c286b087f09a4b56592052512db4ccddb4
6
+ metadata.gz: 0746213df68215e2c00772250d8ad2ad616e75b14b2f813116616f2b5bea1a0c841256bc20cb5ae9bb0c0fa9fbe893db114e1bd34e5e6ce0f634ffb0e6b51976
7
+ data.tar.gz: 5a97cca945e75b2f047dd7b14deac587f50837bd29219d3df9706d9578b7ed5aabac788ba12e54939c5ff8584129fa5d812fbeb9f72a5e7b1e62a65c3537bd7e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.5
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [![Build Status](https://travis-ci.org/EvidentSecurity/esp_sdk.svg?branch=master)](https://travis-ci.org/EvidentSecurity/esp_sdk)
2
2
  [![Code Climate](https://codeclimate.com/repos/546a526f6956800d2900e3fb/badges/841000b5295e533401c3/gpa.svg)](https://codeclimate.com/repos/546a526f6956800d2900e3fb/feed)
3
3
  [![Test Coverage](https://codeclimate.com/repos/546a526f6956800d2900e3fb/badges/841000b5295e533401c3/coverage.svg)](https://codeclimate.com/repos/546a526f6956800d2900e3fb/feed)
4
+ [![Gem Version](https://badge.fury.io/rb/esp_sdk.svg)](http://badge.fury.io/rb/esp_sdk)
4
5
 
5
6
  # EspSdk
6
7
 
@@ -25,9 +25,12 @@ module EspSdk
25
25
  fail MissingAttribute, 'Missing required attributes' if payload.blank?
26
26
  response = RestClient.send(type, url, payload, headers)
27
27
  end
28
- rescue RestClient::UnprocessableEntity, RestClient::Unauthorized => e
28
+ rescue RestClient::Unauthorized => e
29
+ fail EspSdk::Unauthorized, 'Unauthorized request'
30
+ rescue RestClient::UnprocessableEntity => e
29
31
  response = e.response
30
- check_errors(JSON.load(response.body))
32
+ body = JSON.load(response.body) if response.body.present?
33
+ check_errors(JSON.load(body))
31
34
  end
32
35
 
33
36
  response
@@ -4,4 +4,5 @@ module EspSdk
4
4
  class TokenExpired < StandardError; end
5
5
  class RecordNotFound < StandardError; end
6
6
  class Exception < StandardError; end
7
+ class Unauthorized < StandardError; end
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module EspSdk
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -21,6 +21,16 @@ class ClientTest < ActiveSupport::TestCase
21
21
 
22
22
  context '#connect' do
23
23
  setup { @url = 'https://esp.evident.io/api/v1/test' }
24
+
25
+ should 'raise an unauthorized error' do
26
+ RestClient.expects(:get).raises(RestClient::Unauthorized)
27
+ exception = assert_raises EspSdk::Unauthorized do
28
+ @client.connect(@url, :get)
29
+ end
30
+
31
+ assert_equal 'Unauthorized request', exception.message
32
+ end
33
+
24
34
  [:get, :delete].each do |type|
25
35
  should "make #{type} request with headers only" do
26
36
  # Make sure the correct RestClient method is called and arguments are passed
@@ -116,4 +126,4 @@ class ClientTest < ActiveSupport::TestCase
116
126
  end
117
127
  end
118
128
  end
119
- end
129
+ end
@@ -31,5 +31,11 @@ class ExceptionsTest < ActiveSupport::TestCase
31
31
  assert EspSdk::Exception.new.is_a?(StandardError)
32
32
  end
33
33
  end
34
+
35
+ context 'Unauthorized' do
36
+ should 'be a StandardError' do
37
+ assert EspSdk::Unauthorized.new.is_a?(StandardError)
38
+ end
39
+ end
34
40
  end
35
- end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esp_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evident.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  version: '0'
246
246
  requirements: []
247
247
  rubyforge_project:
248
- rubygems_version: 2.2.2
248
+ rubygems_version: 2.4.3
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: SDK for interacting with the ESP API.