validates_truthiness 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/Gemfile.lock +46 -0
- data/LICENSE +22 -0
- data/README.md +91 -0
- data/Rakefile +3 -0
- data/lib/validates_falsity.rb +17 -0
- data/lib/validates_truthiness/version.rb +1 -1
- data/lib/validates_truthiness.rb +3 -1
- data/lib/validates_verity.rb +17 -0
- data/spec/model.rb +13 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/activemodel.rb +1 -0
- data/spec/support/i18n.rb +3 -0
- data/spec/support/languages.yml +15 -0
- data/spec/support/simplecov.rb +5 -0
- data/spec/validates_falsity_spec.rb +79 -0
- data/spec/validates_truthiness_spec.rb +79 -0
- data/spec/validates_verity_spec.rb +79 -0
- data/validates_truthiness.gemspec +31 -15
- metadata +94 -25
data/.gitignore
CHANGED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ruby-1.9.2-p136@validates_truthiness
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
validates_truthiness (0.0.1)
|
5
|
+
activerecord (~> 3.0.3)
|
6
|
+
bundler (~> 1.0.10)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (3.0.3)
|
12
|
+
activesupport (= 3.0.3)
|
13
|
+
builder (~> 2.1.2)
|
14
|
+
i18n (~> 0.4)
|
15
|
+
activerecord (3.0.3)
|
16
|
+
activemodel (= 3.0.3)
|
17
|
+
activesupport (= 3.0.3)
|
18
|
+
arel (~> 2.0.2)
|
19
|
+
tzinfo (~> 0.3.23)
|
20
|
+
activesupport (3.0.3)
|
21
|
+
arel (2.0.7)
|
22
|
+
builder (2.1.2)
|
23
|
+
diff-lcs (1.1.2)
|
24
|
+
i18n (0.5.0)
|
25
|
+
rake (0.8.7)
|
26
|
+
rspec (2.4.0)
|
27
|
+
rspec-core (~> 2.4.0)
|
28
|
+
rspec-expectations (~> 2.4.0)
|
29
|
+
rspec-mocks (~> 2.4.0)
|
30
|
+
rspec-core (2.4.0)
|
31
|
+
rspec-expectations (2.4.0)
|
32
|
+
diff-lcs (~> 1.1.2)
|
33
|
+
rspec-mocks (2.4.0)
|
34
|
+
simplecov (0.3.9)
|
35
|
+
simplecov-html (>= 0.3.7)
|
36
|
+
simplecov-html (0.3.9)
|
37
|
+
tzinfo (0.3.24)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
rake (~> 0.8.7)
|
44
|
+
rspec (~> 2.4)
|
45
|
+
simplecov (~> 0.3.9)
|
46
|
+
validates_truthiness!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2011 The Kompanee - Jeff Felchner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
Truthiness is...
|
2
|
+
================================
|
3
|
+
|
4
|
+
...knowing that one line can make a difference.
|
5
|
+
|
6
|
+
![Truthiness](http://www.thekompanee.com/public_files/truthiness.jpg)
|
7
|
+
|
8
|
+
This is a simple gem with a simple purpose. I love Ruby. One of the biggest
|
9
|
+
reasons why I love Ruby so much is because of its readability. Unfortunately,
|
10
|
+
I'd been forever typing stuff like this:
|
11
|
+
|
12
|
+
validates_inclusion_of :loves_long_walks_on_the_beach, :in => [true, false]
|
13
|
+
|
14
|
+
Is this horrible? Hell no. Do I want to make it better? Hell yes.
|
15
|
+
|
16
|
+
What I really wanted to type was this:
|
17
|
+
|
18
|
+
validates_truthiness_of :loves_long_walks_on_the_beach
|
19
|
+
|
20
|
+
_See 'Aliases' at the bottom if you'd rather have a more unambiguous validation title._ :)
|
21
|
+
|
22
|
+
Installation
|
23
|
+
--------------------------------
|
24
|
+
|
25
|
+
gem install validates_truthiness
|
26
|
+
|
27
|
+
Usage
|
28
|
+
--------------------------------
|
29
|
+
|
30
|
+
You can either use the Rails 2-style to chain multiple columns together:
|
31
|
+
validates_truthiness_of :opting_out_of_newsletters, :consents_to_strip_search
|
32
|
+
|
33
|
+
Or the Rails 3-style:
|
34
|
+
validates :works_hard_for_the_money,
|
35
|
+
truthiness => true
|
36
|
+
|
37
|
+
If you'd like a specific message, say "Yes" or "No" instead of "True" or "False",
|
38
|
+
just pass it as a `:message` option:
|
39
|
+
|
40
|
+
validates :believes_they_may_be_a_cylon,
|
41
|
+
:truthiness => {:message => "must be either a 'Yes' or a fraking 'No'"}
|
42
|
+
|
43
|
+
Also, don't forget you can `:allow_nil` in case you need the triumvirate of:
|
44
|
+
true, false and nothing.
|
45
|
+
|
46
|
+
I18n
|
47
|
+
---------------------------------
|
48
|
+
|
49
|
+
Due to this being wired up through ActiveModel, internationalization is free, just add
|
50
|
+
the proper keys to your .yml files.
|
51
|
+
|
52
|
+
No Stone Unturned
|
53
|
+
---------------------------------
|
54
|
+
|
55
|
+
Just to make sure this was the ULTIMATE boolean validation gem, although I believe use
|
56
|
+
cases for these are slim to none:
|
57
|
+
|
58
|
+
**Validating Truth**
|
59
|
+
|
60
|
+
* `validates_verity_of`
|
61
|
+
* `validates_truth_of`
|
62
|
+
|
63
|
+
**Validating Falsity**
|
64
|
+
|
65
|
+
* `validates_falsity_of`
|
66
|
+
* `validates_falsehood_of`
|
67
|
+
|
68
|
+
Aliases
|
69
|
+
---------------------------------
|
70
|
+
|
71
|
+
In case some of you aren't fond of the ambiguity of "truthiness" I've also aliased `validates_truthiness_of` to `validates_booleanship_of`
|
72
|
+
|
73
|
+
Issues
|
74
|
+
------
|
75
|
+
|
76
|
+
If you have problems, please create a [Github issue](https://github.com/jfelchner/validates_truthiness/issues).
|
77
|
+
|
78
|
+
Credits
|
79
|
+
-------
|
80
|
+
|
81
|
+
![thekompanee](http://www.thekompanee.com/public_files/kompanee-github-readme-logo.png)
|
82
|
+
|
83
|
+
validates_truthiness is maintained by [The Kompanee, Ltd.](http://www.thekompanee.com)
|
84
|
+
|
85
|
+
The names and logos for The Kompanee are trademarks of The Kompanee, Ltd.
|
86
|
+
|
87
|
+
License
|
88
|
+
-------
|
89
|
+
|
90
|
+
validates_truthiness is Copyright © 2011 The Kompanee. It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
91
|
+
|
data/Rakefile
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveModel
|
2
|
+
module Validations
|
3
|
+
class FalsityValidator < ActiveModel::EachValidator
|
4
|
+
def validate_each(record, attribute, value)
|
5
|
+
record.errors.add(attribute, :falsity, :message => options[:message], :value => value) unless value.is_a?(FalseClass)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module HelperMethods
|
10
|
+
def validates_falsity_of(*attr_names)
|
11
|
+
validates_with FalsityValidator, _merge_attributes(attr_names)
|
12
|
+
end
|
13
|
+
|
14
|
+
alias validates_falsehood_of validates_falsity_of
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/validates_truthiness.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveModel
|
|
2
2
|
module Validations
|
3
3
|
class TruthinessValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(record, attribute, value)
|
5
|
-
record.errors
|
5
|
+
record.errors.add(attribute, :truthiness, :message => options[:message], :value => value) unless (value.is_a?(FalseClass) || value.is_a?(TrueClass))
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -10,6 +10,8 @@ module ActiveModel
|
|
10
10
|
def validates_truthiness_of(*attr_names)
|
11
11
|
validates_with TruthinessValidator, _merge_attributes(attr_names)
|
12
12
|
end
|
13
|
+
|
14
|
+
alias validates_booleanship_of validates_truthiness_of
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveModel
|
2
|
+
module Validations
|
3
|
+
class VerityValidator < ActiveModel::EachValidator
|
4
|
+
def validate_each(record, attribute, value)
|
5
|
+
record.errors.add(attribute, :verity, :message => options[:message], :value => value) unless value.is_a?(TrueClass)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module HelperMethods
|
10
|
+
def validates_verity_of(*attr_names)
|
11
|
+
validates_with VerityValidator, _merge_attributes(attr_names)
|
12
|
+
end
|
13
|
+
|
14
|
+
alias validates_truth_of validates_verity_of
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/model.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Object.class_eval { remove_const :Truthteller if const_defined?(:Truthteller) }
|
2
|
+
|
3
|
+
class Truthteller
|
4
|
+
include ActiveModel::Validations
|
5
|
+
|
6
|
+
attr_accessor :i_am_not_a_crook,
|
7
|
+
:the_sky_is_blue,
|
8
|
+
:puppies_are_cute
|
9
|
+
|
10
|
+
def initialize(true_or_false)
|
11
|
+
@i_am_not_a_crook, @the_sky_is_blue, @puppies_are_cute = true_or_false, true_or_false, true_or_false
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "active_model"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
activemodel:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
truthiness: "must be either true or false"
|
6
|
+
verity: "must be true"
|
7
|
+
falsity: "must be false"
|
8
|
+
|
9
|
+
pt-BR:
|
10
|
+
activemodel:
|
11
|
+
errors:
|
12
|
+
messages:
|
13
|
+
truthiness: "deve ser verdadeira ou falsa"
|
14
|
+
verity: "deve ser verdadeira"
|
15
|
+
falsity: "deve ser falsa"
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "validates_falsity")
|
4
|
+
|
5
|
+
describe ".validates_falsity_of" do
|
6
|
+
it "allows false" do
|
7
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook
|
8
|
+
|
9
|
+
truthteller = Truthteller.new(false)
|
10
|
+
truthteller.should be_valid
|
11
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
12
|
+
end
|
13
|
+
|
14
|
+
it "does not allow true" do
|
15
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook
|
16
|
+
|
17
|
+
truthteller = Truthteller.new(true)
|
18
|
+
truthteller.should_not be_valid
|
19
|
+
truthteller.errors[:i_am_not_a_crook].should_not be_empty
|
20
|
+
end
|
21
|
+
|
22
|
+
it "works with Rails 3-style validation syntax" do
|
23
|
+
Truthteller.validates :i_am_not_a_crook, :falsity => true
|
24
|
+
Truthteller.validates :puppies_are_cute, :falsity => true
|
25
|
+
|
26
|
+
truthteller = Truthteller.new(false)
|
27
|
+
truthteller.i_am_not_a_crook = false
|
28
|
+
truthteller.puppies_are_cute = "foo"
|
29
|
+
|
30
|
+
truthteller.should_not be_valid
|
31
|
+
truthteller.errors[:puppies_are_cute].should_not be_empty
|
32
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shows the English error message" do
|
36
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook
|
37
|
+
|
38
|
+
truthteller = Truthteller.new("foo")
|
39
|
+
truthteller.should_not be_valid
|
40
|
+
truthteller.errors[:i_am_not_a_crook].should == ["must be false"]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "shows the supplied error message if provided" do
|
44
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook, :message => "must answer 'yes'"
|
45
|
+
|
46
|
+
truthteller = Truthteller.new("foo")
|
47
|
+
truthteller.should_not be_valid
|
48
|
+
truthteller.errors[:i_am_not_a_crook].should == ["must answer 'yes'"]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "shows use I18n string as error message" do
|
52
|
+
I18n.locale = :'pt-BR'
|
53
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook
|
54
|
+
|
55
|
+
truthteller = Truthteller.new("foo")
|
56
|
+
truthteller.should_not be_valid
|
57
|
+
truthteller.errors[:i_am_not_a_crook].should == ["deve ser falsa"]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "rejects nil value" do
|
61
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook
|
62
|
+
|
63
|
+
truthteller = Truthteller.new(nil)
|
64
|
+
truthteller.should_not be_valid
|
65
|
+
truthteller.errors[:i_am_not_a_crook].should_not be_empty
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does not reject nil value when asked not to" do
|
69
|
+
Truthteller.validates_falsity_of :i_am_not_a_crook, :allow_nil => true
|
70
|
+
|
71
|
+
truthteller = Truthteller.new(nil)
|
72
|
+
truthteller.should be_valid
|
73
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
74
|
+
end
|
75
|
+
|
76
|
+
it "aliases validates_truth_of" do
|
77
|
+
Truthteller.should respond_to(:validates_falsehood_of)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "validates_truthiness")
|
4
|
+
|
5
|
+
describe ".validates_truthiness_of" do
|
6
|
+
it "allows true" do
|
7
|
+
Truthteller.validates_truthiness_of :i_am_not_a_crook
|
8
|
+
|
9
|
+
truthteller = Truthteller.new(true)
|
10
|
+
truthteller.should be_valid
|
11
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
12
|
+
end
|
13
|
+
|
14
|
+
it "allows false" do
|
15
|
+
Truthteller.validates_truthiness_of :i_am_not_a_crook
|
16
|
+
|
17
|
+
truthteller = Truthteller.new(false)
|
18
|
+
truthteller.should be_valid
|
19
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
20
|
+
end
|
21
|
+
|
22
|
+
it "works with Rails 3-style validation syntax" do
|
23
|
+
Truthteller.validates :i_am_not_a_crook, :truthiness => true
|
24
|
+
Truthteller.validates :puppies_are_cute, :truthiness => true
|
25
|
+
|
26
|
+
truthteller = Truthteller.new(true)
|
27
|
+
truthteller.puppies_are_cute = "foo"
|
28
|
+
truthteller.i_am_not_a_crook = true
|
29
|
+
|
30
|
+
truthteller.should_not be_valid
|
31
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
32
|
+
truthteller.errors[:puppies_are_cute].should_not be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shows the English error message" do
|
36
|
+
Truthteller.validates_truthiness_of :i_am_not_a_crook
|
37
|
+
|
38
|
+
truthteller = Truthteller.new("foo")
|
39
|
+
truthteller.should_not be_valid
|
40
|
+
truthteller.errors[:i_am_not_a_crook].should == ["must be either true or false"]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "shows the supplied error message if provided" do
|
44
|
+
Truthteller.validates_truthiness_of :the_sky_is_blue, :message => "must be either yes or no"
|
45
|
+
|
46
|
+
truthteller = Truthteller.new("foo")
|
47
|
+
truthteller.should_not be_valid
|
48
|
+
truthteller.errors[:the_sky_is_blue].should == ["must be either yes or no"]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "shows use I18n string as error message" do
|
52
|
+
I18n.locale = :'pt-BR'
|
53
|
+
Truthteller.validates_truthiness_of :puppies_are_cute
|
54
|
+
|
55
|
+
truthteller = Truthteller.new("foo")
|
56
|
+
truthteller.should_not be_valid
|
57
|
+
truthteller.errors[:puppies_are_cute].should == ["deve ser verdadeira ou falsa"]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "rejects nil value" do
|
61
|
+
Truthteller.validates_truthiness_of :i_am_not_a_crook
|
62
|
+
|
63
|
+
truthteller = Truthteller.new(nil)
|
64
|
+
truthteller.should_not be_valid
|
65
|
+
truthteller.errors[:i_am_not_a_crook].should_not be_empty
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does not reject nil value when asked not to" do
|
69
|
+
Truthteller.validates_truthiness_of :i_am_not_a_crook, :allow_nil => true
|
70
|
+
|
71
|
+
truthteller = Truthteller.new(nil)
|
72
|
+
truthteller.should be_valid
|
73
|
+
truthteller.errors[:i_am_not_a_crook].should be_empty
|
74
|
+
end
|
75
|
+
|
76
|
+
it "aliases validates_booleanship_of" do
|
77
|
+
Truthteller.should respond_to(:validates_booleanship_of)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "validates_verity")
|
4
|
+
|
5
|
+
describe ".validates_verity_of" do
|
6
|
+
it "allows true" do
|
7
|
+
Truthteller.validates_verity_of :i_am_not_a_crook
|
8
|
+
|
9
|
+
truthteller = Truthteller.new(true)
|
10
|
+
truthteller.should be_valid
|
11
|
+
truthteller.errors[:puppies_are_cute].should be_empty
|
12
|
+
end
|
13
|
+
|
14
|
+
it "does not allow false", :focused => true do
|
15
|
+
Truthteller.validates_verity_of :puppies_are_cute
|
16
|
+
|
17
|
+
truthteller = Truthteller.new(false)
|
18
|
+
truthteller.should_not be_valid
|
19
|
+
truthteller.errors[:puppies_are_cute].should_not be_empty
|
20
|
+
end
|
21
|
+
|
22
|
+
it "works with Rails 3-style validation syntax" do
|
23
|
+
Truthteller.validates :i_am_not_a_crook, :verity => true
|
24
|
+
Truthteller.validates :puppies_are_cute, :verity => true
|
25
|
+
|
26
|
+
truthteller = Truthteller.new(true)
|
27
|
+
truthteller.puppies_are_cute = true
|
28
|
+
truthteller.i_am_not_a_crook = "foo"
|
29
|
+
|
30
|
+
truthteller.should_not be_valid
|
31
|
+
truthteller.errors[:i_am_not_a_crook].should_not be_empty
|
32
|
+
truthteller.errors[:puppies_are_cute].should be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shows the English error message" do
|
36
|
+
Truthteller.validates_verity_of :puppies_are_cute
|
37
|
+
|
38
|
+
truthteller = Truthteller.new("foo")
|
39
|
+
truthteller.should_not be_valid
|
40
|
+
truthteller.errors[:puppies_are_cute].should == ["must be true"]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "shows the supplied error message if provided" do
|
44
|
+
Truthteller.validates_verity_of :puppies_are_cute, :message => "must answer 'yes'"
|
45
|
+
|
46
|
+
truthteller = Truthteller.new("foo")
|
47
|
+
truthteller.should_not be_valid
|
48
|
+
truthteller.errors[:puppies_are_cute].should == ["must answer 'yes'"]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "shows use I18n string as error message" do
|
52
|
+
I18n.locale = :'pt-BR'
|
53
|
+
Truthteller.validates_verity_of :puppies_are_cute
|
54
|
+
|
55
|
+
truthteller = Truthteller.new("foo")
|
56
|
+
truthteller.should_not be_valid
|
57
|
+
truthteller.errors[:puppies_are_cute].should == ["deve ser verdadeira"]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "rejects nil value" do
|
61
|
+
Truthteller.validates_verity_of :puppies_are_cute
|
62
|
+
|
63
|
+
truthteller = Truthteller.new(nil)
|
64
|
+
truthteller.should_not be_valid
|
65
|
+
truthteller.errors[:puppies_are_cute].should_not be_empty
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does not reject nil value when asked not to" do
|
69
|
+
Truthteller.validates_verity_of :puppies_are_cute, :allow_nil => true
|
70
|
+
|
71
|
+
truthteller = Truthteller.new(nil)
|
72
|
+
truthteller.should be_valid
|
73
|
+
truthteller.errors[:puppies_are_cute].should be_empty
|
74
|
+
end
|
75
|
+
|
76
|
+
it "aliases validates_truth_of" do
|
77
|
+
Truthteller.should respond_to(:validates_truth_of)
|
78
|
+
end
|
79
|
+
end
|
@@ -3,19 +3,35 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
require "validates_truthiness/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.
|
7
|
-
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
|
14
|
-
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
s.
|
19
|
-
s.
|
20
|
-
|
6
|
+
s.rubygems_version = '1.4.2'
|
7
|
+
|
8
|
+
s.name = "validates_truthiness"
|
9
|
+
s.rubyforge_project = "validates_truthiness"
|
10
|
+
|
11
|
+
s.version = ValidatesTruthiness::VERSION
|
12
|
+
s.platform = Gem::Platform::RUBY
|
13
|
+
|
14
|
+
s.authors = ["thekompanee", "jfelchner"]
|
15
|
+
s.email = 'support@thekompanee.com'
|
16
|
+
s.homepage = 'http://github.com/jfelchner/apple_cart'
|
17
|
+
|
18
|
+
s.summary = "validates_truthiness-#{ValidatesTruthiness::VERSION}"
|
19
|
+
s.description = %q[Makes boolean validations a little cleaner.]
|
20
|
+
|
21
|
+
s.rdoc_options = ["--charset = UTF-8"]
|
22
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
23
|
+
|
24
|
+
#= Manifest =#
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.files = `git ls-files`.split("\n")
|
27
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
#= Manifest =#
|
30
|
+
|
31
|
+
s.add_dependency('activerecord', '~> 3.0.3')
|
32
|
+
s.add_dependency('bundler', '~> 1.0.10')
|
33
|
+
|
34
|
+
s.add_development_dependency('rspec', '~> 2.4')
|
35
|
+
s.add_development_dependency('rake', '~> 0.8.7')
|
36
|
+
s.add_development_dependency('simplecov', '~> 0.3.9')
|
21
37
|
end
|
metadata
CHANGED
@@ -1,47 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_truthiness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
|
-
- jfelchner
|
13
8
|
- thekompanee
|
9
|
+
- jfelchner
|
14
10
|
autorequire:
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
13
|
|
18
|
-
date: 2011-01
|
14
|
+
date: 2011-02-01 00:00:00 -06:00
|
19
15
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activerecord
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 3.0.3
|
26
|
+
type: :runtime
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.10
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: rspec
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "2.4"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rake
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 0.8.7
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: simplecov
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.3.9
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id005
|
22
72
|
description: Makes boolean validations a little cleaner.
|
23
|
-
email:
|
24
|
-
- support@thekompanee.com
|
73
|
+
email: support@thekompanee.com
|
25
74
|
executables: []
|
26
75
|
|
27
76
|
extensions: []
|
28
77
|
|
29
|
-
extra_rdoc_files:
|
30
|
-
|
78
|
+
extra_rdoc_files:
|
79
|
+
- README.md
|
80
|
+
- LICENSE
|
31
81
|
files:
|
32
82
|
- .gitignore
|
83
|
+
- .rvmrc
|
33
84
|
- Gemfile
|
85
|
+
- Gemfile.lock
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
34
88
|
- Rakefile
|
89
|
+
- lib/validates_falsity.rb
|
35
90
|
- lib/validates_truthiness.rb
|
36
91
|
- lib/validates_truthiness/version.rb
|
92
|
+
- lib/validates_verity.rb
|
93
|
+
- spec/model.rb
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
- spec/support/activemodel.rb
|
96
|
+
- spec/support/i18n.rb
|
97
|
+
- spec/support/languages.yml
|
98
|
+
- spec/support/simplecov.rb
|
99
|
+
- spec/validates_falsity_spec.rb
|
100
|
+
- spec/validates_truthiness_spec.rb
|
101
|
+
- spec/validates_verity_spec.rb
|
37
102
|
- validates_truthiness.gemspec
|
38
103
|
has_rdoc: true
|
39
|
-
homepage:
|
104
|
+
homepage: http://github.com/jfelchner/apple_cart
|
40
105
|
licenses: []
|
41
106
|
|
42
107
|
post_install_message:
|
43
|
-
rdoc_options:
|
44
|
-
|
108
|
+
rdoc_options:
|
109
|
+
- --charset = UTF-8
|
45
110
|
require_paths:
|
46
111
|
- lib
|
47
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -49,23 +114,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
114
|
requirements:
|
50
115
|
- - ">="
|
51
116
|
- !ruby/object:Gem::Version
|
52
|
-
segments:
|
53
|
-
- 0
|
54
117
|
version: "0"
|
55
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
119
|
none: false
|
57
120
|
requirements:
|
58
121
|
- - ">="
|
59
122
|
- !ruby/object:Gem::Version
|
60
|
-
segments:
|
61
|
-
- 0
|
62
123
|
version: "0"
|
63
124
|
requirements: []
|
64
125
|
|
65
126
|
rubyforge_project: validates_truthiness
|
66
|
-
rubygems_version: 1.
|
127
|
+
rubygems_version: 1.5.0
|
67
128
|
signing_key:
|
68
129
|
specification_version: 3
|
69
|
-
summary: validates_truthiness
|
70
|
-
test_files:
|
71
|
-
|
130
|
+
summary: validates_truthiness-0.1.0
|
131
|
+
test_files:
|
132
|
+
- spec/model.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
- spec/support/activemodel.rb
|
135
|
+
- spec/support/i18n.rb
|
136
|
+
- spec/support/languages.yml
|
137
|
+
- spec/support/simplecov.rb
|
138
|
+
- spec/validates_falsity_spec.rb
|
139
|
+
- spec/validates_truthiness_spec.rb
|
140
|
+
- spec/validates_verity_spec.rb
|