finapps_core 2.0.3 → 2.0.4

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: f37837d2b8bcb2f90e068539256a41ec589530ec
4
- data.tar.gz: b05a2cb8fb0c36e4764392a78fe13d8ef80ea39d
3
+ metadata.gz: 393d3128a7c11cf6c09f606ad1a330a96b005857
4
+ data.tar.gz: 944722feeedee32d4d2e20f32ce9c6fb70b8d6f2
5
5
  SHA512:
6
- metadata.gz: 715a1bda039a60ce2fe8a2e8ba09a0a37354dbd2734f122e76889007541e3150f34534c9318d9f2aca490b651028cb1568a603ef76c515768e4a2088a1c7d284
7
- data.tar.gz: 7e168a213eb4fccf532934eaac25147d4c4b7e62d101b19a5a4d5528676166ededa8c661e874d5332c41096aa0feb7fd8d4251ae378f7395e0b60e83670796ab
6
+ metadata.gz: 7c6b157cddb7120e43819c0928059e4e6afb607c41485079b2a75f847fd3ee91a9d1e91620bde7ac8628d8ab11df0d8061ec2a2d0a1aa6ada5f01a313f65b9ee
7
+ data.tar.gz: 76fdaca3c806008470b02a94781ebbf83e815eb891443ea49eeb5487579f4bc8a59c48483dd80057dd1e1f2bef55612256ad388d0549d1e13b1ae0b1f4f1a531
data/.travis.yml CHANGED
@@ -12,3 +12,5 @@ notifications:
12
12
  addons:
13
13
  code_climate:
14
14
  repo_token: 5a8d194cbc23aa4c171e3478e3b6bbea9dd96041071380ec25bf80c07770b39a
15
+ after_success:
16
+ - bundle exec codeclimate-test-reporter
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- finapps_core (2.0.2)
4
+ finapps_core (2.0.3)
5
5
  faraday (~> 0.11, >= 0.11.0)
6
6
  faraday_middleware (~> 0.11, >= 0.11.0)
7
7
  rash (~> 0.4, >= 0.4.0)
@@ -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
- %i(InvalidArgumentsError MissingArgumentsError ApiSessionTimeoutError).each do |const|
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(Faraday::Error::ConnectionFailed, '407 "Proxy Authentication Required"')
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::InvalidArgumentsError.new "Method not supported: #{method}."
110
+ raise FinAppsCore::UnsupportedHttpMethodError.new "Method not supported: #{method}."
114
111
  end
115
112
  end
116
113
  end
@@ -6,7 +6,7 @@ module FinAppsCore
6
6
  def logger
7
7
  @logger ||= begin
8
8
  require 'logger'
9
- ::Logger.new(STDOUT)
9
+ Logger.new(STDOUT).tap {|log| log.level = Logger::FATAL }
10
10
  end
11
11
  end
12
12
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module FinAppsCore
3
- VERSION = '2.0.3'
3
+ VERSION = '2.0.4'
4
4
  end
@@ -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::InvalidArgumentsError,
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, &:status)[RESPONSE]).to eq(200)
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.3
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-07 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday