foraneus 0.0.8 → 0.0.9
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/lib/foraneus.rb +6 -2
- data/spec/lib/foraneus_spec.rb +36 -0
- 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: 976c68b16acbcc76530fda47381d9ab002e2af0e
|
4
|
+
data.tar.gz: 3c76aa959fc3e5677a75479b11b153de3e6126a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef995adf323dd314630b41305a9ba4ca6744cad7fe8e0b8a1a02eb72dc491f0124c7f49ae9b94f301f6fb7afba8d5a130949a62dd370c8a19dd45678f0bde6f6
|
7
|
+
data.tar.gz: 035ad2c188843583faf6dd2313ba263e9c94493263037964f584419c6693b28d14c778dfa64bacd4388d2b369b1cd0d1261aefd1feebef1d08e1c056c56877ac
|
data/lib/foraneus.rb
CHANGED
@@ -190,9 +190,13 @@ class Foraneus
|
|
190
190
|
|
191
191
|
return unless converter
|
192
192
|
|
193
|
-
if
|
193
|
+
if v == '' && converter.opts.fetch(:blanks_as_nil, true)
|
194
|
+
v = nil
|
195
|
+
end
|
196
|
+
|
197
|
+
if v.nil? && converter.opts[:required]
|
194
198
|
raise KeyError, "required parameter not found: #{field.inspect}"
|
195
|
-
elsif v.nil?
|
199
|
+
elsif v.nil?
|
196
200
|
v = nil
|
197
201
|
else
|
198
202
|
v = converter.parse(v)
|
data/spec/lib/foraneus_spec.rb
CHANGED
@@ -39,6 +39,18 @@ describe Foraneus do
|
|
39
39
|
|
40
40
|
its([]) { should include('delay' => '5') }
|
41
41
|
end
|
42
|
+
|
43
|
+
context 'when empty strings' do
|
44
|
+
let(:converter) { Foraneus::Converters::String.new }
|
45
|
+
|
46
|
+
subject(:form) { form_spec.parse(:delay => '') }
|
47
|
+
|
48
|
+
its(:delay) { should eq(nil) }
|
49
|
+
|
50
|
+
its(:data) { should include(:delay => nil) }
|
51
|
+
|
52
|
+
it { should be_valid }
|
53
|
+
end
|
42
54
|
end
|
43
55
|
|
44
56
|
context 'with non parseable data' do
|
@@ -89,6 +101,30 @@ describe Foraneus do
|
|
89
101
|
it { should be_valid }
|
90
102
|
end
|
91
103
|
|
104
|
+
context 'when a field is declared as allow blanks = true' do
|
105
|
+
let(:converter) { Foraneus::Converters::String.new(:blanks_as_nil => true) }
|
106
|
+
|
107
|
+
subject(:form) { form_spec.parse(:delay => '') }
|
108
|
+
|
109
|
+
its(:delay) { should be_nil }
|
110
|
+
|
111
|
+
its(:data) { should include(:delay => nil) }
|
112
|
+
|
113
|
+
its([:delay]) { should eq('') }
|
114
|
+
|
115
|
+
its([]) { should include(:delay => '') }
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when a field is declared as blanks_as_nil = false' do
|
119
|
+
let(:converter) { Foraneus::Converters::String.new(:blanks_as_nil => false) }
|
120
|
+
|
121
|
+
subject(:form) { form_spec.parse(:delay => '') }
|
122
|
+
|
123
|
+
its(:delay) { should eq('') }
|
124
|
+
|
125
|
+
its(:data) { should include(:delay => '') }
|
126
|
+
end
|
127
|
+
|
92
128
|
shared_examples 'an absent parameters handler' do |missing_value|
|
93
129
|
subject(:form) { form_spec.parse(:delay => missing_value) }
|
94
130
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foraneus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianfranco Zas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|