remind101 0.2.0 → 0.2.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: 1e634a534ebd0a1286e7583d315615a8796c06ff
4
- data.tar.gz: b25cf0eb73962fed9269b6373fc75117687a0007
3
+ metadata.gz: 1faa05e29b28622fcfda12de219e9a633596a989
4
+ data.tar.gz: c69839a0a708c5d79e291126442c70ddefe32aca
5
5
  SHA512:
6
- metadata.gz: 37534508d3f2990ded85119d03ffa3ea1d19f31f22d615423981910d1f486ae0abda76742e3c4b318c15744b7a5676e41b96eec3fff30a9765f6dd5d31814e10
7
- data.tar.gz: 132ed59a5d7787aedc4f64f40a6906697b04181da767149a5273de3ef5a4b16a2ef3989089e1b9ec60e22e927a34d9b490dd6a59942011a1b8e21634fc7e2bd4
6
+ metadata.gz: 070b8ae9bf4b8228b874e2a7b428e991755a129d06f7bd05d92eb080c85b5af2012997d0c8b42889e8c843bd7bc59546c0ab1d99f306e650a7143979b83b0963
7
+ data.tar.gz: a949cbf125c0b7a8318c5d5405a070b1a0093f68a154f3e77c48a8b2fb7f2fe9c806254044cd88eb11ff14594b3c1235580cf5d8cd309af7ab5ca1ba22a5e29e
@@ -1,9 +1,8 @@
1
1
  module Remind101
2
2
  module Error
3
- # White label faraday's errors.
4
- Faraday::Error.constants.each do |const|
5
- const_set(const, Faraday::Error.const_get(const))
6
- end
3
+ ClientError = Class.new(Faraday::Error::ClientError)
4
+ ResourceNotFound = Class.new(ClientError)
5
+ ConnectionFailed = Class.new(ClientError)
7
6
 
8
7
  module ErrorsBody
9
8
  def error
@@ -11,6 +10,10 @@ module Remind101
11
10
  end
12
11
  end
13
12
 
13
+ class Unauthorized < ClientError
14
+ include ErrorsBody
15
+ end
16
+
14
17
  class BadInput < ClientError
15
18
  include ErrorsBody
16
19
  end
@@ -7,6 +7,8 @@ module Remind101
7
7
  case env[:status]
8
8
  when 400
9
9
  raise Remind101::Error::BadInput, response_values(env)
10
+ when 401
11
+ raise Remind101::Error::Unauthorized, response_values(env)
10
12
  when 404
11
13
  raise Remind101::Error::ResourceNotFound, response_values(env)
12
14
  when 422
@@ -1,3 +1,3 @@
1
1
  module Remind101
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Remind101::Error do
4
+ specify { Remind101::Error::ClientError.should inherit_from Faraday::ClientError }
5
+
6
+ [
7
+ Remind101::Error::BadInput,
8
+ Remind101::Error::Unauthorized,
9
+ Remind101::Error::ResourceNotFound,
10
+ Remind101::Error::ValidationError,
11
+ Remind101::Error::ConnectionFailed
12
+ ].each do |klass|
13
+ specify { klass.should inherit_from Remind101::Error::ClientError }
14
+ end
15
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,3 +11,9 @@ WebMock.disable_net_connect!
11
11
  # Requires supporting ruby files with custom matchers and macros, etc,
12
12
  # in spec/support/ and its subdirectories.
13
13
  Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}
14
+
15
+ RSpec::Matchers.define :inherit_from do |expected|
16
+ match do |actual|
17
+ actual < expected
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remind101
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric J. Holmes
@@ -177,6 +177,7 @@ files:
177
177
  - lib/remind101/version.rb
178
178
  - remind101.gemspec
179
179
  - spec/remind101/client_spec.rb
180
+ - spec/remind101/error_spec.rb
180
181
  - spec/remind101_spec.rb
181
182
  - spec/spec_helper.rb
182
183
  homepage: https://github.com/remind101/remind101.rb
@@ -205,5 +206,6 @@ specification_version: 4
205
206
  summary: Ruby client for the Remind101 API.
206
207
  test_files:
207
208
  - spec/remind101/client_spec.rb
209
+ - spec/remind101/error_spec.rb
208
210
  - spec/remind101_spec.rb
209
211
  - spec/spec_helper.rb