deeply_valid 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/deeply_valid.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deeply_valid}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Starr Horne"]
@@ -17,7 +17,7 @@ module DeeplyValid
17
17
  #
18
18
  def initialize(rule = nil, &block)
19
19
 
20
- if !rule && !block_given?
20
+ if rule.nil? && !block_given?
21
21
  raise "No validation rule specified"
22
22
  end
23
23
 
@@ -132,6 +132,15 @@ module DeeplyValid
132
132
  end
133
133
  end
134
134
 
135
+ #
136
+ # Validate true or false
137
+ #
138
+ # @return [Validation] The validation
139
+ #
140
+ def boolean
141
+ any(true, false)
142
+ end
143
+
135
144
  #
136
145
  # Validate all keys / values in a hash
137
146
  #
@@ -76,6 +76,19 @@ class ValidationHelpersTest < Test::Unit::TestCase
76
76
 
77
77
  end
78
78
 
79
+
80
+ context "boolean helper" do
81
+
82
+ should "validate correctly" do
83
+ assert Sample.boolean.valid?(true)
84
+ assert Sample.boolean.valid?(false)
85
+ assert !Sample.boolean.valid?(nil)
86
+ assert !Sample.boolean.valid?("")
87
+ assert !Sample.boolean.valid?(123)
88
+ end
89
+
90
+ end
91
+
79
92
  context "date helper" do
80
93
 
81
94
  should "validate correctly" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Starr Horne