fat_zebra 3.0.1 → 3.0.2

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: 0ac27cea9c7baf7c382f97bb6eadeede98ebdd03
4
- data.tar.gz: 31a7ebdd9646a45834a478ae3b8d2cbb142232fa
3
+ metadata.gz: b9a4b0c24c9b0a769d463452e4c1826477908e7c
4
+ data.tar.gz: e023bcc5106aad407e116d72db57c81c3c9b0c0f
5
5
  SHA512:
6
- metadata.gz: c8e625b2825444e7cc694e751d3ec572ed17a2560255fe096882089033192c7306ed6e8a46dbf2fc20c57469b0011df4cde81b05c2725e6727326ec74dbf670c
7
- data.tar.gz: 7fd6085163d5071a61e61a934b5c2c6a1d5d59146799e3759341549d5eb246075f8eee37ccdc25d2a7aa13e92cc20c19c2003dc7c4ae9495ca7d9578224f5dce
6
+ metadata.gz: 85db673360acbb895e0e5560eedc8bf5a6683417173769266232e0dc8a61a97a1d5a56ab4ae4065a8c696e679ed7798923dd021077f16c8b4e6f5a20e7e28910
7
+ data.tar.gz: 04a5cc56c681b18ebd1ab9c26ff573c5903d1a3aa79c1eafe12852a3d8f8314139ffbe10ed2052c100db2eb66689a841bb94ce46c894d0be307ee86aea71aa33
@@ -22,6 +22,7 @@ module FatZebra
22
22
  #
23
23
  # @return [Hash] response
24
24
  # @raise [FatZebra::RequestError] if the request is invalid
25
+ # rubocop:disable Metrics/AbcSize
25
26
  def request(method, path, payload = {}, options = {})
26
27
  payload[:test] = true if configurations.test_mode
27
28
  payload = Util.format_dates_in_hash(payload)
@@ -36,10 +37,12 @@ module FatZebra
36
37
  use_ssl: configurations.http_secure
37
38
  ).merge(authentication).merge(default_headers).merge(configurations.global_options).merge(options)
38
39
 
39
- request = Request.execute(request_options)
40
-
41
- request.body
40
+ Request.execute(request_options).body
41
+ rescue FatZebra::RequestError => error
42
+ return error.http_body if error.http_status == 422
43
+ raise
42
44
  end
45
+ # rubocop:enable Metrics/AbcSize
43
46
 
44
47
  private
45
48
 
@@ -1,3 +1,3 @@
1
1
  module FatZebra
2
- VERSION = '3.0.1'.freeze
2
+ VERSION = '3.0.2'.freeze
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe FatZebra::APIResource do
4
+
5
+ describe '#request' do
6
+ subject(:resource) { FatZebra::APIResource.request(:post, '/test') }
7
+
8
+ context 'with errors' do
9
+ before { allow(FatZebra::Request).to receive(:execute).and_raise(FatZebra::RequestError.new(response)) }
10
+
11
+ context 'with Net::HTTPUnprocessableEntity' do
12
+ let(:response) { double('response', code: '422', code_type: Net::HTTPUnprocessableEntity, body: {}.to_json, message: 'failed') }
13
+
14
+ it { expect { resource }.to_not raise_error }
15
+ end
16
+
17
+ context 'with Net::HTTPBadRequest' do
18
+ let(:response) { double('response', code: '400', code_type: Net::HTTPBadRequest, body: {}.to_json, message: 'failed') }
19
+
20
+ it { expect { resource }.to raise_error(FatZebra::RequestError) }
21
+ end
22
+ end
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_zebra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -361,6 +361,7 @@ files:
361
361
  - spec/cassettes/FatZebra_WebHook/_update/1_3_2.yml
362
362
  - spec/cassettes/FatZebra_WebHook/_update/1_3_3.yml
363
363
  - spec/fixtures/batch_test.csv
364
+ - spec/lib/fat_zebra/api_resource_spec.rb
364
365
  - spec/lib/fat_zebra/bank_account_spec.rb
365
366
  - spec/lib/fat_zebra/batch_spec.rb
366
367
  - spec/lib/fat_zebra/card_spec.rb