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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7095e2ddf14cea0d459266e69bbad1d13b70ffac
4
- data.tar.gz: 9979ccfad3d33a3d776332bbca66fe7b12821d4c
3
+ metadata.gz: 20b09c6d50f86d7f24c352ab06dd360dcfdddd17
4
+ data.tar.gz: 6f41391c9ba5051d30b955cf5c4cded6cac9300e
5
5
  SHA512:
6
- metadata.gz: 00e364f6c550713c25580d61aba432e0f2c6e7cdfbfabe1545ee0e8bee16d5d494a3c49632afab2ad1a557094df6474eb824be7d964d02b443d3ec7a103aad85
7
- data.tar.gz: 1f3bda3cb4d84c2ac152fe731b5b5b069ee0b3321106c72d87c5c00bd3e00a83a21e791321d4cd1067a1cb2d69b1d8bc4bf07d08b8facb10a4134e996696c0ad
6
+ metadata.gz: 33d6a1955b2b84b54451cf2fcb89da5543ead8fce45e7f8d769db15a4927b367aaabf24179e91dd335fc472bcf51b49d4ccec5bb64d41e925ebc7b106b18fc6d
7
+ data.tar.gz: 82f101246fb38fb16b44aa4b7b3c10cd6f553958bbe85f0caee4f81e9d89281bf359fd258de73e1a133a8c573d512c73905e03c44d2c07b0cb7a457e6dd4e649
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Conduit
2
- VERSION = '0.6.2'
2
+ VERSION = '0.6.3'
3
3
  end
@@ -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
 
@@ -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.2
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-05-11 00:00:00.000000000 Z
11
+ date: 2015-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport