input_sanitizer 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -45,6 +45,11 @@ class InputSanitizer::Sanitizer
|
|
45
45
|
:date => InputSanitizer::DateConverter.new,
|
46
46
|
:time => InputSanitizer::TimeConverter.new,
|
47
47
|
:boolean => InputSanitizer::BooleanConverter.new,
|
48
|
+
:integer_or_blank => InputSanitizer::IntegerConverter.new.extend(InputSanitizer::AllowNil),
|
49
|
+
:string_or_blank => InputSanitizer::StringConverter.new.extend(InputSanitizer::AllowNil),
|
50
|
+
:date_or_blank => InputSanitizer::DateConverter.new.extend(InputSanitizer::AllowNil),
|
51
|
+
:time_or_blank => InputSanitizer::TimeConverter.new.extend(InputSanitizer::AllowNil),
|
52
|
+
:boolean_or_blank => InputSanitizer::BooleanConverter.new.extend(InputSanitizer::AllowNil),
|
48
53
|
}
|
49
54
|
end
|
50
55
|
|
@@ -1,6 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'input_sanitizer/extended_converters'
|
3
3
|
|
4
|
+
describe InputSanitizer::AllowNil do
|
5
|
+
it "passes blanks" do
|
6
|
+
lambda { |_| 1 }.extend(InputSanitizer::AllowNil).call("").should be_nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "passes things the extended sanitizer passes" do
|
10
|
+
lambda { |_| :something }.extend(InputSanitizer::AllowNil).call(:stuff).
|
11
|
+
should eq(:something)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises error if the extended sanitizer raises error" do
|
15
|
+
action = lambda do
|
16
|
+
lambda { |_| raise "Some error" }.extend(InputSanitizer::AllowNil).call(:stuff)
|
17
|
+
end
|
18
|
+
|
19
|
+
action.should raise_error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
4
23
|
describe InputSanitizer::PositiveIntegerConverter do
|
5
24
|
let(:converter) { InputSanitizer::PositiveIntegerConverter.new }
|
6
25
|
|
data/spec/sanitizer_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: input_sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.8.
|
96
|
+
rubygems_version: 1.8.23
|
97
97
|
signing_key:
|
98
98
|
specification_version: 3
|
99
99
|
summary: Gem to sanitize hash of incoming data
|