finapps_core 2.0.3 → 2.0.4
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 +4 -4
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -1
- data/lib/finapps_core/error.rb +10 -1
- data/lib/finapps_core/middleware/response/raise_error.rb +1 -1
- data/lib/finapps_core/rest/base_client.rb +1 -4
- data/lib/finapps_core/utils/loggeable.rb +1 -1
- data/lib/finapps_core/version.rb +1 -1
- data/spec/rest/base_client_spec.rb +4 -15
- data/spec/spec_helper.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 393d3128a7c11cf6c09f606ad1a330a96b005857
|
4
|
+
data.tar.gz: 944722feeedee32d4d2e20f32ce9c6fb70b8d6f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c6b157cddb7120e43819c0928059e4e6afb607c41485079b2a75f847fd3ee91a9d1e91620bde7ac8628d8ab11df0d8061ec2a2d0a1aa6ada5f01a313f65b9ee
|
7
|
+
data.tar.gz: 76fdaca3c806008470b02a94781ebbf83e815eb891443ea49eeb5487579f4bc8a59c48483dd80057dd1e1f2bef55612256ad388d0549d1e13b1ae0b1f4f1a531
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/finapps_core/error.rb
CHANGED
@@ -3,15 +3,24 @@
|
|
3
3
|
module FinAppsCore # :nodoc:
|
4
4
|
# Base error class.
|
5
5
|
class Error < StandardError; end
|
6
|
+
|
6
7
|
# Raised for existing but invalid arguments.
|
7
8
|
class InvalidArgumentsError < Error; end
|
9
|
+
|
8
10
|
# Raised whenever a required argument is missing.
|
9
11
|
class MissingArgumentsError < Error; end
|
10
12
|
|
11
13
|
# Raised whenever there is a session timeout at the API.
|
12
14
|
class ApiSessionTimeoutError < Error; end
|
13
15
|
|
14
|
-
|
16
|
+
# Raised whenever the request specify an unsupported HTTP method.
|
17
|
+
class UnsupportedHttpMethodError < Error; end
|
18
|
+
|
19
|
+
# Raised whenever the connection fails.
|
20
|
+
class ConnectionFailedError < Error; end
|
21
|
+
|
22
|
+
%i(InvalidArgumentsError MissingArgumentsError ApiSessionTimeoutError
|
23
|
+
UnsupportedHttpMethodError ConnectionFailedError).each do |const|
|
15
24
|
Error.const_set(const, FinAppsCore.const_get(const))
|
16
25
|
end
|
17
26
|
end
|
@@ -15,7 +15,7 @@ module FinAppsCore
|
|
15
15
|
if env[:status] == API_SESSION_TIMEOUT
|
16
16
|
raise(FinAppsCore::Error::ApiSessionTimeoutError, 'Api Session Timed out')
|
17
17
|
elsif env[:status] == CONNECTION_FAILED_STATUS
|
18
|
-
raise(
|
18
|
+
raise(FinAppsCore::Error::ConnectionFailedError, 'Connection Failed')
|
19
19
|
else
|
20
20
|
raise(Faraday::Error::ClientError, response_values(env))
|
21
21
|
end
|
@@ -73,9 +73,6 @@ module FinAppsCore
|
|
73
73
|
|
74
74
|
begin
|
75
75
|
response = execute_method path, method, params
|
76
|
-
|
77
|
-
rescue FinAppsCore::ApiSessionTimeoutError => error
|
78
|
-
handle_error(error)
|
79
76
|
rescue FinAppsCore::InvalidArgumentsError => error
|
80
77
|
handle_error error
|
81
78
|
rescue FinAppsCore::MissingArgumentsError => error
|
@@ -110,7 +107,7 @@ module FinAppsCore
|
|
110
107
|
when :delete
|
111
108
|
delete(path, params)
|
112
109
|
else
|
113
|
-
raise FinAppsCore::
|
110
|
+
raise FinAppsCore::UnsupportedHttpMethodError.new "Method not supported: #{method}."
|
114
111
|
end
|
115
112
|
end
|
116
113
|
end
|
data/lib/finapps_core/version.rb
CHANGED
@@ -30,7 +30,7 @@ RSpec.describe FinAppsCore::REST::BaseClient do
|
|
30
30
|
|
31
31
|
describe '#send_request' do
|
32
32
|
it 'should raise FinAppsCore::InvalidArgumentsError if method is NOT supported' do
|
33
|
-
expect { subject.send_request('fake_path', :option) }.to raise_error(FinAppsCore::
|
33
|
+
expect { subject.send_request('fake_path', :option) }.to raise_error(FinAppsCore::UnsupportedHttpMethodError,
|
34
34
|
'Method not supported: option.')
|
35
35
|
end
|
36
36
|
|
@@ -53,15 +53,6 @@ RSpec.describe FinAppsCore::REST::BaseClient do
|
|
53
53
|
expect(subject.size).to eq(return_array.length)
|
54
54
|
end
|
55
55
|
|
56
|
-
context 'for unsupported methods' do
|
57
|
-
subject { FinAppsCore::REST::BaseClient.new(valid_tenant_options).send_request('users', :options) }
|
58
|
-
|
59
|
-
it do
|
60
|
-
expect { subject.send_request(nil, :get) }
|
61
|
-
.to raise_error(FinAppsCore::InvalidArgumentsError, 'Method not supported: options.')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
56
|
context 'for client errors' do
|
66
57
|
subject { FinAppsCore::REST::BaseClient.new(valid_tenant_options).send_request('client_error', :get) }
|
67
58
|
|
@@ -81,15 +72,13 @@ RSpec.describe FinAppsCore::REST::BaseClient do
|
|
81
72
|
|
82
73
|
context 'for proxy errors' do
|
83
74
|
subject { FinAppsCore::REST::BaseClient.new(valid_tenant_options).send_request('proxy_error', :get) }
|
84
|
-
|
85
|
-
it { expect { subject }.to raise_error(Faraday::ConnectionFailed, '407 "Proxy Authentication Required"') }
|
75
|
+
it { expect { subject }.to raise_error(FinAppsCore::ConnectionFailedError, 'Connection Failed') }
|
86
76
|
end
|
87
77
|
end
|
88
78
|
|
89
79
|
context 'if a block is provided' do
|
90
|
-
it('gets executed on the response') do
|
91
|
-
expect(subject.send_request('relevance/ruleset/names', :get
|
92
|
-
expect(subject.send_request('relevance/ruleset/names', :get) {|r| r.body.length }[RESPONSE]).to eq(45)
|
80
|
+
it('gets executed on the response and returned as the result') do
|
81
|
+
expect(subject.send_request('relevance/ruleset/names', :get) {|r| r.body.length }).to eq([45, []])
|
93
82
|
end
|
94
83
|
end
|
95
84
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
if ENV['CODECLIMATE_REPO_TOKEN']
|
3
|
-
require 'codeclimate-test-reporter'
|
4
|
-
CodeClimate::TestReporter.start
|
3
|
+
# require 'codeclimate-test-reporter'
|
4
|
+
# CodeClimate::TestReporter.start
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start
|
5
7
|
end
|
6
8
|
|
7
9
|
require 'bundler/setup'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|