conduit 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conduit/core/action.rb +26 -0
- data/lib/conduit/core/connection.rb +4 -0
- data/lib/conduit/version.rb +1 -1
- data/spec/classes/core/action_spec.rb +27 -0
- data/spec/spec_helper.rb +2 -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: 20b09c6d50f86d7f24c352ab06dd360dcfdddd17
|
4
|
+
data.tar.gz: 6f41391c9ba5051d30b955cf5c4cded6cac9300e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d6a1955b2b84b54451cf2fcb89da5543ead8fce45e7f8d769db15a4927b367aaabf24179e91dd335fc472bcf51b49d4ccec5bb64d41e925ebc7b106b18fc6d
|
7
|
+
data.tar.gz: 82f101246fb38fb16b44aa4b7b3c10cd6f553958bbe85f0caee4f81e9d89281bf359fd258de73e1a133a8c573d512c73905e03c44d2c07b0cb7a457e6dd4e649
|
data/lib/conduit/core/action.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
#
|
14
14
|
|
15
15
|
require 'active_support/inflector'
|
16
|
+
require 'active_support/core_ext/object/blank'
|
16
17
|
require 'forwardable'
|
17
18
|
require 'ostruct'
|
18
19
|
require 'set'
|
@@ -139,11 +140,36 @@ module Conduit
|
|
139
140
|
# an ArgumentError listing missing attributes
|
140
141
|
#
|
141
142
|
def validate!(options)
|
143
|
+
!missing_required_keys?(options) &&
|
144
|
+
!required_keys_not_present?(options)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Raises an Argument error if any required keys
|
148
|
+
# are not present in the options hash; otherwise
|
149
|
+
# returns false
|
150
|
+
#
|
151
|
+
def missing_required_keys?(options)
|
142
152
|
missing_keys = (requirements.to_a - options.keys)
|
143
153
|
if missing_keys.any?
|
144
154
|
raise ArgumentError,
|
145
155
|
"Missing keys: #{missing_keys.join(', ')}"
|
146
156
|
end
|
157
|
+
false
|
158
|
+
end
|
159
|
+
|
160
|
+
# Raises an Argument error if any required keys
|
161
|
+
# are present in the options hash but have nil values;
|
162
|
+
# otherwise returns false
|
163
|
+
#
|
164
|
+
def required_keys_not_present?(options)
|
165
|
+
required_options_not_present = requirements.reject do |required_key|
|
166
|
+
options[required_key].present?
|
167
|
+
end
|
168
|
+
if required_options_not_present.any?
|
169
|
+
raise ArgumentError,
|
170
|
+
"Nil keys: #{required_options_not_present.join(', ')}"
|
171
|
+
end
|
172
|
+
false
|
147
173
|
end
|
148
174
|
|
149
175
|
# Returns the parser for this action
|
@@ -54,6 +54,10 @@ module Conduit
|
|
54
54
|
raise(Conduit::Timeout, timeout.message)
|
55
55
|
rescue Excon::Errors::Error => error
|
56
56
|
raise(Conduit::ConnectionError, error.message)
|
57
|
+
rescue SocketError => error
|
58
|
+
msg = 'Could not connect to the server. Please check your internet connection.' +
|
59
|
+
"\n#{error.message}"
|
60
|
+
raise(Conduit::ConnectionError, msg)
|
57
61
|
end
|
58
62
|
|
59
63
|
private
|
data/lib/conduit/version.rb
CHANGED
@@ -40,6 +40,33 @@ shared_examples_for Conduit::Core::Action do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe '.new' do
|
44
|
+
it 'should raise an error if any required arguments are not supplied' do
|
45
|
+
expect { described_class.new({}) }.to raise_error(ArgumentError)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should raise an error if any required arguments are nil' do
|
49
|
+
options = request_attributes.inject({}) do |h, (k, _v)|
|
50
|
+
h.merge(k => nil)
|
51
|
+
end
|
52
|
+
expect { described_class.new(options) }.to raise_error(ArgumentError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should raise an error if any of the required arguments are blank' do
|
56
|
+
options = request_attributes.inject({}) do |h, (k, _v)|
|
57
|
+
h.merge(k => '')
|
58
|
+
end
|
59
|
+
expect { described_class.new(options) }.to raise_error(ArgumentError)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should raise an error if any of the required arguments are empty' do
|
63
|
+
options = request_attributes.inject({}) do |h, (k, _v)|
|
64
|
+
h.merge(k => [])
|
65
|
+
end
|
66
|
+
expect { described_class.new(options) }.to raise_error(ArgumentError)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
43
70
|
describe '#perform' do
|
44
71
|
before { Excon.stub({}, body: response, status: 200) }
|
45
72
|
|
data/spec/spec_helper.rb
CHANGED
@@ -18,7 +18,7 @@ RSpec.configure do |config|
|
|
18
18
|
config.include Helper
|
19
19
|
|
20
20
|
config.expect_with :rspec do |c|
|
21
|
-
c.syntax = :should
|
21
|
+
c.syntax = [:should, :expect]
|
22
22
|
end
|
23
23
|
|
24
24
|
config.before(:suite) do
|
@@ -29,4 +29,4 @@ RSpec.configure do |config|
|
|
29
29
|
|
30
30
|
Conduit::Driver.load_drivers
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conduit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kelley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|