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 +4 -4
- data/lib/fat_zebra/api_resource.rb +6 -3
- data/lib/fat_zebra/version.rb +1 -1
- data/spec/lib/fat_zebra/api_resource_spec.rb +25 -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: b9a4b0c24c9b0a769d463452e4c1826477908e7c
|
4
|
+
data.tar.gz: e023bcc5106aad407e116d72db57c81c3c9b0c0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
|
data/lib/fat_zebra/version.rb
CHANGED
@@ -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.
|
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-
|
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
|