conduit 1.0.4 → 1.1.0
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 +4 -2
- data/lib/conduit/version.rb +1 -1
- data/spec/classes/core/action_spec.rb +19 -4
- data/spec/support/helper.rb +4 -3
- data/spec/support/my_driver/actions/foo.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b37e7362d4af2ed4841798aff5b04f2285cce7eb
|
4
|
+
data.tar.gz: 99da695bd5abdb9233a3957482741ea9b05dc1fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37d02a757f479664b1eac37eff9e07e45c7b4ef254b5311e96961818f2d5f663e545508ca10cd1e001e8eb706b9bbba3dc5a689f2f477ca43944a1f17d187659
|
7
|
+
data.tar.gz: 84b2e662f55f271a1aad27044ff3ea14379de08014faa24cb15a637ff1ffcedadaddfdc7b6e2a29bfe121276fbf79850d57866145dde2c0e35ed0b8d510a4a75
|
data/lib/conduit/core/action.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# e.g.
|
6
6
|
# => class MyAction < Conduit::Core::Action
|
7
|
-
# => required_attributes :foo, :bar
|
7
|
+
# => required_attributes :foo, :bar, [:either, :or]
|
8
8
|
# => optional_attributes :baz
|
9
9
|
# => end
|
10
10
|
#
|
@@ -107,7 +107,7 @@ module Conduit
|
|
107
107
|
# will default to `nil`.
|
108
108
|
#
|
109
109
|
def attributes_with_values
|
110
|
-
attributes.inject({}) do |hash, attribute|
|
110
|
+
attributes.to_a.flatten.inject({}) do |hash, attribute|
|
111
111
|
hash.tap do |h|
|
112
112
|
h[attribute] = @options[attribute]
|
113
113
|
end
|
@@ -168,6 +168,8 @@ module Conduit
|
|
168
168
|
#
|
169
169
|
def validate!(options)
|
170
170
|
missing_keys = (requirements.to_a - options.keys)
|
171
|
+
either_keys = requirements.select { |key| key.is_a?(Array) }
|
172
|
+
missing_keys.reject! { |key| either_keys.any? { |either| (either & options.keys).present? }}
|
171
173
|
if missing_keys.any?
|
172
174
|
raise ArgumentError,
|
173
175
|
"Missing keys: #{missing_keys.join(', ')}"
|
data/lib/conduit/version.rb
CHANGED
@@ -17,26 +17,41 @@ shared_examples_for Conduit::Core::Action do
|
|
17
17
|
|
18
18
|
describe '.requirements' do
|
19
19
|
it 'returns an array of required attributes' do
|
20
|
-
subject.class.requirements.should == [:foo, :bar, :baz].to_set
|
20
|
+
subject.class.requirements.should == [:foo, :bar, :baz, [:either, :or]].to_set
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '.attributes' do
|
25
25
|
it 'returns an array of known attributes' do
|
26
|
-
subject.class.requirements.should == [:foo, :bar, :baz].to_set
|
26
|
+
subject.class.requirements.should == [:foo, :bar, :baz, [:either, :or]].to_set
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
context "action has an array in its required_attibutes field" do
|
32
|
+
let(:attrs) { request_attributes }
|
33
|
+
it "raises an error if missing both of the keys" do
|
34
|
+
attrs.delete(:either)
|
35
|
+
attrs.delete(:or)
|
36
|
+
lambda { described_class.new(attrs) }.should raise_error(ArgumentError)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "doesn't raise an error if only one key is missing" do
|
40
|
+
attrs.delete(:either)
|
41
|
+
attrs[:or] = "value of or"
|
42
|
+
lambda { described_class.new(attrs) }.should_not raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
31
46
|
context 'with an instance' do
|
32
47
|
describe '#attributes_with_values' do
|
33
48
|
context 'with optional attribute not set' do
|
34
|
-
let (:attrs) { request_attributes.merge(buz: nil) }
|
49
|
+
let (:attrs) { request_attributes.merge(buz: nil, or: nil) }
|
35
50
|
its(:attributes_with_values) { should eq(attrs) }
|
36
51
|
end
|
37
52
|
|
38
53
|
context 'with optional attribute set' do
|
39
|
-
let (:attrs) { request_attributes.merge(buz: "value for buz") }
|
54
|
+
let (:attrs) { request_attributes.merge(buz: "value for buz", or: nil) }
|
40
55
|
subject { described_class.new(attrs) }
|
41
56
|
its(:attributes_with_values) { should eq(attrs) }
|
42
57
|
end
|
data/spec/support/helper.rb
CHANGED
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kelley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.6.7
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Conduit is an interface for debit platforms.
|
@@ -262,3 +262,4 @@ test_files:
|
|
262
262
|
- spec/support/xml/xml_modified_request.xml
|
263
263
|
- spec/support/xml/xml_request.xml
|
264
264
|
- spec/support/xml/xml_response.xml
|
265
|
+
has_rdoc:
|