validatable 1.6.6 → 1.6.7
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.
- data/lib/errors.rb +2 -2
- data/rakefile.rb +1 -2
- data/test/test_helper.rb +1 -0
- data/test/unit/errors_test.rb +17 -3
- data/test/unit/understandable_test.rb +3 -5
- data/test/unit/validatable_test.rb +31 -33
- data/test/unit/validates_acceptance_of_test.rb +5 -5
- data/test/unit/validates_confirmation_of_test.rb +22 -21
- data/test/unit/validates_format_of_test.rb +10 -11
- data/test/unit/validates_length_of_test.rb +64 -66
- data/test/unit/validates_numericality_of_test.rb +44 -46
- data/test/unit/validates_presence_of_test.rb +8 -7
- data/test/unit/validates_true_for_test.rb +8 -9
- data/test/unit/validation_base_test.rb +1 -1
- metadata +41 -34
data/lib/errors.rb
CHANGED
@@ -14,7 +14,7 @@ module Validatable
|
|
14
14
|
return nil if errors[attribute.to_sym].nil?
|
15
15
|
errors[attribute.to_sym].size == 1 ? errors[attribute.to_sym].first : errors[attribute.to_sym]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def add(attribute, message) #:nodoc:
|
19
19
|
errors[attribute.to_sym] = [] if errors[attribute.to_sym].nil?
|
20
20
|
errors[attribute.to_sym] << message
|
@@ -44,7 +44,7 @@ module Validatable
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def count #:nodoc:
|
47
|
-
size
|
47
|
+
errors.values.flatten.size
|
48
48
|
end
|
49
49
|
|
50
50
|
# call-seq: full_messages -> an_array_of_messages
|
data/rakefile.rb
CHANGED
@@ -29,7 +29,7 @@ Gem::manage_gems
|
|
29
29
|
specification = Gem::Specification.new do |s|
|
30
30
|
s.name = "validatable"
|
31
31
|
s.summary = "Validatable is a library for adding validations."
|
32
|
-
s.version = "1.6.
|
32
|
+
s.version = "1.6.7"
|
33
33
|
s.author = 'Jay Fields'
|
34
34
|
s.description = "Validatable is a library for adding validations."
|
35
35
|
s.email = 'validatable-developer@rubyforge.org'
|
@@ -40,7 +40,6 @@ specification = Gem::Specification.new do |s|
|
|
40
40
|
s.extra_rdoc_files = ['README']
|
41
41
|
s.rdoc_options << '--title' << 'Validatable' << '--main' << 'README' << '--line-numbers'
|
42
42
|
|
43
|
-
s.autorequire = 'validatable'
|
44
43
|
s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*$', 'rakefile.rb'].to_a
|
45
44
|
s.test_file = "test/all_tests.rb"
|
46
45
|
end
|
data/test/test_helper.rb
CHANGED
data/test/unit/errors_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
3
|
+
Expectations do
|
4
4
|
expect "message" do
|
5
5
|
errors = Validatable::Errors.new
|
6
6
|
errors.add(:attribute, "message")
|
@@ -37,8 +37,8 @@ class ErrorsTest < Test::Unit::TestCase
|
|
37
37
|
errors.full_messages.sort
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
expect true do
|
41
|
+
Validatable::Errors.included_modules.include?(Enumerable)
|
42
42
|
end
|
43
43
|
|
44
44
|
expect ["message1", "message2"] do
|
@@ -47,4 +47,18 @@ class ErrorsTest < Test::Unit::TestCase
|
|
47
47
|
errors.add(:attribute, "message2")
|
48
48
|
errors.on(:attribute)
|
49
49
|
end
|
50
|
+
|
51
|
+
expect 2 do
|
52
|
+
errors = Validatable::Errors.new
|
53
|
+
errors.add(:attribute, "message1")
|
54
|
+
errors.add(:attribute, "message2")
|
55
|
+
errors.count
|
56
|
+
end
|
57
|
+
|
58
|
+
expect 2 do
|
59
|
+
errors = Validatable::Errors.new
|
60
|
+
errors.add(:attribute1, "message1")
|
61
|
+
errors.add(:attribute2, "message2")
|
62
|
+
errors.count
|
63
|
+
end
|
50
64
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Expectations do
|
4
|
+
expect [:c, :b, :a] do
|
5
5
|
a = Class.new do
|
6
6
|
include Validatable::Understandable
|
7
7
|
understands :a
|
8
8
|
end
|
9
|
-
|
10
9
|
b = Class.new(a) do
|
11
10
|
include Validatable::Understandable
|
12
11
|
understands :b
|
@@ -15,7 +14,6 @@ class UnderstandableTest < Test::Unit::TestCase
|
|
15
14
|
include Validatable::Understandable
|
16
15
|
understands :c
|
17
16
|
end
|
18
|
-
|
19
|
-
assert_array_equal [:a, :b, :c], c.all_understandings
|
17
|
+
c.all_understandings
|
20
18
|
end
|
21
19
|
end
|
@@ -1,40 +1,38 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
validations << validation
|
10
|
-
end
|
11
|
-
klass.new.valid?
|
3
|
+
Expectations do
|
4
|
+
expect false do
|
5
|
+
validation = stub_everything(:should_validate? => true, :attribute => "attribute", :level => 1, :groups => [])
|
6
|
+
klass = Class.new do
|
7
|
+
include Validatable
|
8
|
+
validations << validation
|
12
9
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
instance.errors.add(:attribute, "message")
|
20
|
-
instance.valid?
|
21
|
-
instance.errors.empty?
|
10
|
+
klass.new.valid?
|
11
|
+
end
|
12
|
+
|
13
|
+
expect true do
|
14
|
+
klass = Class.new do
|
15
|
+
include Validatable
|
22
16
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
instance = klass.new
|
18
|
+
instance.errors.add(:attribute, "message")
|
19
|
+
instance.valid?
|
20
|
+
instance.errors.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
expect false do
|
24
|
+
klass = Class.new do
|
25
|
+
include Validatable
|
29
26
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
klass.validation_keys_include?("anything")
|
28
|
+
end
|
29
|
+
|
30
|
+
expect true do
|
31
|
+
validation = stub_everything(:key => "key")
|
32
|
+
klass = Class.new do
|
33
|
+
include Validatable
|
34
|
+
validations << validation
|
38
35
|
end
|
36
|
+
klass.validation_keys_include?("key")
|
39
37
|
end
|
40
|
-
end
|
38
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Expectations do
|
4
|
+
expect true do
|
5
5
|
validation = Validatable::ValidatesAcceptanceOf.new stub_everything, :acceptance
|
6
6
|
instance = stub(:acceptance=>'true')
|
7
|
-
|
7
|
+
validation.valid?(instance)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
expect false do
|
11
11
|
validation = Validatable::ValidatesAcceptanceOf.new stub_everything, :acceptance
|
12
12
|
instance = stub(:acceptance=>'false')
|
13
|
-
|
13
|
+
validation.valid?(instance)
|
14
14
|
end
|
15
15
|
|
16
16
|
expect true do
|
@@ -1,58 +1,59 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Expectations do
|
4
|
+
|
5
|
+
expect true do
|
5
6
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username
|
6
7
|
instance = stub(:username=>"username", :username_confirmation=>"username")
|
7
|
-
|
8
|
+
validation.valid?(instance)
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
+
expect false do
|
11
12
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username
|
12
13
|
instance = stub(:username=>"username", :username_confirmation=>"usessrname")
|
13
|
-
|
14
|
+
validation.valid?(instance)
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
+
expect true do
|
17
18
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
|
18
19
|
instance = stub(:username=>"username", :username_confirmation=>"USERNAME")
|
19
|
-
|
20
|
+
validation.valid?(instance)
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
+
expect false do
|
23
24
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
|
24
25
|
instance = stub(:username=>"username", :username_confirmation=>"USERNAME")
|
25
|
-
|
26
|
+
validation.valid?(instance)
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
expect false do
|
29
30
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
|
30
|
-
|
31
|
+
validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
+
expect false do
|
34
35
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
|
35
|
-
|
36
|
+
validation.valid?(stub(:username => 'something', :username_confirmation => nil))
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
+
expect true do
|
39
40
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => true
|
40
|
-
|
41
|
+
validation.valid?(stub(:username => nil, :username_confirmation => nil))
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
+
expect false do
|
44
45
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
|
45
|
-
|
46
|
+
validation.valid?(stub(:username => nil, :username_confirmation => 'something'))
|
46
47
|
end
|
47
48
|
|
48
|
-
|
49
|
+
expect false do
|
49
50
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
|
50
|
-
|
51
|
+
validation.valid?(stub(:username => 'something', :username_confirmation => nil))
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
+
expect true do
|
54
55
|
validation = Validatable::ValidatesConfirmationOf.new stub_everything, :username, :case_sensitive => false
|
55
|
-
|
56
|
+
validation.valid?(stub(:username => nil, :username_confirmation => nil))
|
56
57
|
end
|
57
58
|
|
58
59
|
expect true do
|
@@ -1,25 +1,24 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Expectations do
|
4
|
+
|
5
|
+
expect false do
|
5
6
|
validation = Validatable::ValidatesFormatOf.new stub_everything, :name, :with => /book/
|
6
|
-
|
7
|
+
validation.valid?(stub_everything)
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
+
expect true do
|
10
11
|
validation = Validatable::ValidatesFormatOf.new stub_everything, :name, :with => /book/
|
11
|
-
|
12
|
+
validation.valid?(stub(:name=>"book"))
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
+
expect true do
|
15
16
|
validation = Validatable::ValidatesFormatOf.new stub_everything, :age, :with => /14/
|
16
|
-
|
17
|
+
validation.valid?(stub(:age=>14))
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
validation = Validatable::ValidatesFormatOf.new stub_everything, :age
|
22
|
-
end
|
20
|
+
expect ArgumentError do
|
21
|
+
validation = Validatable::ValidatesFormatOf.new stub_everything, :age
|
23
22
|
end
|
24
23
|
|
25
24
|
expect true do
|
@@ -1,77 +1,75 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
test "min length" do
|
11
|
-
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2
|
12
|
-
instance = stub(:username=>"u")
|
13
|
-
assert_equal false, validation.valid?(instance)
|
14
|
-
end
|
3
|
+
Expectations do
|
4
|
+
expect false do
|
5
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :maximum => 8
|
6
|
+
validation.valid?(stub(:username=>"usernamefdfd"))
|
7
|
+
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
test "is length is false" do
|
23
|
-
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
|
24
|
-
instance = stub(:username=>"u")
|
25
|
-
assert_equal false, validation.valid?(instance)
|
26
|
-
end
|
27
|
-
|
28
|
-
test "is length is true" do
|
29
|
-
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
|
30
|
-
instance = stub(:username=>"uu")
|
31
|
-
assert_equal true, validation.valid?(instance)
|
32
|
-
end
|
33
|
-
|
34
|
-
test "within lower bound is true" do
|
35
|
-
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
|
36
|
-
instance = stub(:username => "aa")
|
37
|
-
assert_equal true, validation.valid?(instance)
|
38
|
-
end
|
9
|
+
expect false do
|
10
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2
|
11
|
+
instance = stub(:username=>"u")
|
12
|
+
validation.valid?(instance)
|
13
|
+
end
|
39
14
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
15
|
+
expect true do
|
16
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :minimum => 2, :maximum => 8
|
17
|
+
instance = stub(:username=>"udfgdf")
|
18
|
+
validation.valid?(instance)
|
19
|
+
end
|
20
|
+
|
21
|
+
expect false do
|
22
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
|
23
|
+
instance = stub(:username=>"u")
|
24
|
+
validation.valid?(instance)
|
25
|
+
end
|
26
|
+
|
27
|
+
expect true do
|
28
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :is => 2
|
29
|
+
instance = stub(:username=>"uu")
|
30
|
+
validation.valid?(instance)
|
31
|
+
end
|
32
|
+
|
33
|
+
expect true do
|
34
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
|
35
|
+
instance = stub(:username => "aa")
|
36
|
+
validation.valid?(instance)
|
37
|
+
end
|
45
38
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
expect false do
|
40
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
|
41
|
+
instance = stub(:username => "a")
|
42
|
+
validation.valid?(instance)
|
43
|
+
end
|
44
|
+
|
45
|
+
expect true do
|
46
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
|
47
|
+
instance = stub(:username => "aaaa")
|
48
|
+
validation.valid?(instance)
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
expect false do
|
52
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
|
53
|
+
instance = stub(:username => "aaaaa")
|
54
|
+
validation.valid?(instance)
|
55
|
+
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
expect false do
|
58
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4
|
59
|
+
instance = stub(:username => nil)
|
60
|
+
validation.valid?(instance)
|
61
|
+
end
|
63
62
|
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
|
64
|
+
expect true do
|
65
|
+
validation = Validatable::ValidatesLengthOf.new stub_everything, :username, :within => 2..4, :allow_nil => true
|
66
|
+
instance = stub(:username => nil)
|
67
|
+
validation.valid?(instance)
|
68
|
+
end
|
69
|
+
|
70
|
+
expect true do
|
71
|
+
options = [:message, :if, :times, :level, :groups, :maximum, :minimum, :is, :within, :allow_nil]
|
72
|
+
Validatable::ValidatesLengthOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
|
76
73
|
end
|
74
|
+
|
77
75
|
end
|
@@ -1,54 +1,52 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
class ValidatesNumericalityOfTest < Test::Unit::TestCase
|
3
|
+
Expectations do
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
expect false do
|
6
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :nothing
|
7
|
+
instance = stub(:nothing => nil)
|
8
|
+
validation.valid?(instance)
|
9
|
+
end
|
10
|
+
|
11
|
+
expect true do
|
12
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_int
|
13
|
+
instance = stub(:some_int => 50)
|
14
|
+
validation.valid?(instance)
|
15
|
+
end
|
16
|
+
|
17
|
+
expect true do
|
18
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal
|
19
|
+
instance = stub(:some_decimal => 1.23)
|
20
|
+
validation.valid?(instance)
|
21
|
+
end
|
22
|
+
|
23
|
+
expect false do
|
24
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal, :only_integer => true
|
25
|
+
instance = stub(:some_decimal => 1.23)
|
26
|
+
validation.valid?(instance)
|
27
|
+
end
|
11
28
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
test "when value is an decimal then valid is true" do
|
19
|
-
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_decimal
|
20
|
-
instance = stub(:some_decimal => 1.23)
|
21
|
-
assert_equal true, validation.valid?(instance)
|
22
|
-
end
|
29
|
+
expect true do
|
30
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_negative_number, :only_integer => true
|
31
|
+
instance = stub(:some_negative_number => "-1")
|
32
|
+
validation.valid?(instance)
|
33
|
+
end
|
23
34
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
test "when value has non numeric characters then valid is false" do
|
37
|
-
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_non_numeric
|
38
|
-
instance = stub(:some_non_numeric => "50F")
|
39
|
-
assert_equal false, validation.valid?(instance)
|
40
|
-
end
|
35
|
+
expect false do
|
36
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :some_non_numeric
|
37
|
+
instance = stub(:some_non_numeric => "50F")
|
38
|
+
validation.valid?(instance)
|
39
|
+
end
|
40
|
+
|
41
|
+
expect false do
|
42
|
+
validation = Validatable::ValidatesNumericalityOf.new stub_everything, :multiple_dots
|
43
|
+
instance = stub(:multiple_dots => "50.0.0")
|
44
|
+
validation.valid?(instance)
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
assert_equal false, validation.valid?(instance)
|
46
|
-
end
|
47
|
-
|
48
|
-
expect true do
|
49
|
-
options = [:message, :if, :times, :level, :groups, :only_integer]
|
50
|
-
Validatable::ValidatesNumericalityOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
|
51
|
-
end
|
52
|
-
|
47
|
+
expect true do
|
48
|
+
options = [:message, :if, :times, :level, :groups, :only_integer]
|
49
|
+
Validatable::ValidatesNumericalityOf.new(stub_everything, :test).must_understand(options.to_blank_options_hash)
|
53
50
|
end
|
51
|
+
|
54
52
|
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Expectations do
|
4
|
+
|
5
|
+
expect false do
|
5
6
|
validation = Validatable::ValidatesPresenceOf.new stub_everything, :name
|
6
|
-
|
7
|
+
validation.valid?(stub_everything)
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
+
expect true do
|
10
11
|
validation = Validatable::ValidatesPresenceOf.new stub_everything, :name
|
11
|
-
|
12
|
+
validation.valid?(stub(:name=>"book"))
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
+
expect true do
|
15
16
|
validation = Validatable::ValidatesPresenceOf.new stub_everything, :employee
|
16
|
-
|
17
|
+
validation.valid?(stub(:employee => stub(:nil? => false)))
|
17
18
|
end
|
18
19
|
|
19
20
|
expect true do
|
@@ -1,20 +1,19 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Expectations do
|
4
|
+
|
5
|
+
expect false do
|
5
6
|
validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { false }
|
6
|
-
|
7
|
+
validation.valid?(stub_everything)
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
+
expect true do
|
10
11
|
validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { true }
|
11
|
-
|
12
|
+
validation.valid?(stub_everything)
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
validation = Validatable::ValidatesTrueFor.new stub_everything, :age
|
17
|
-
end
|
15
|
+
expect ArgumentError do
|
16
|
+
validation = Validatable::ValidatesTrueFor.new stub_everything, :age
|
18
17
|
end
|
19
18
|
|
20
19
|
expect true do
|
metadata
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: validatable
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.6.
|
7
|
-
date: 2007-11-04 00:00:00 -04:00
|
8
|
-
summary: Validatable is a library for adding validations.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: validatable-developer@rubyforge.org
|
12
|
-
homepage: http://validatable.rubyforge.org
|
13
|
-
rubyforge_project: validatable
|
14
|
-
description: Validatable is a library for adding validations.
|
15
|
-
autorequire: validatable
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.6.7
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Jay Fields
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-20 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Validatable is a library for adding validations.
|
17
|
+
email: validatable-developer@rubyforge.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
31
24
|
files:
|
32
25
|
- lib/child_validation.rb
|
33
26
|
- lib/errors.rb
|
@@ -72,21 +65,35 @@ files:
|
|
72
65
|
- test/unit/validation_base_test.rb
|
73
66
|
- rakefile.rb
|
74
67
|
- README
|
75
|
-
|
76
|
-
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://validatable.rubyforge.org
|
70
|
+
post_install_message:
|
77
71
|
rdoc_options:
|
78
72
|
- --title
|
79
73
|
- Validatable
|
80
74
|
- --main
|
81
75
|
- README
|
82
76
|
- --line-numbers
|
83
|
-
|
84
|
-
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
89
91
|
requirements: []
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
+
rubyforge_project: validatable
|
94
|
+
rubygems_version: 1.0.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 2
|
97
|
+
summary: Validatable is a library for adding validations.
|
98
|
+
test_files:
|
99
|
+
- test/all_tests.rb
|