mattmatt-validatable 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +116 -0
- data/Rakefile +33 -0
- data/VERSION.yml +5 -0
- data/lib/validatable.rb +28 -0
- data/lib/validatable/child_validation.rb +15 -0
- data/lib/validatable/errors.rb +93 -0
- data/lib/validatable/included_validation.rb +9 -0
- data/lib/validatable/macros.rb +314 -0
- data/lib/validatable/object_extension.rb +21 -0
- data/lib/validatable/requireable.rb +26 -0
- data/lib/validatable/understandable.rb +31 -0
- data/lib/validatable/validatable_class_methods.rb +87 -0
- data/lib/validatable/validatable_instance_methods.rb +106 -0
- data/lib/validatable/validations/validates_acceptance_of.rb +14 -0
- data/lib/validatable/validations/validates_associated.rb +13 -0
- data/lib/validatable/validations/validates_confirmation_of.rb +23 -0
- data/lib/validatable/validations/validates_each.rb +14 -0
- data/lib/validatable/validations/validates_exclusion_of.rb +17 -0
- data/lib/validatable/validations/validates_format_of.rb +16 -0
- data/lib/validatable/validations/validates_inclusion_of.rb +17 -0
- data/lib/validatable/validations/validates_length_of.rb +30 -0
- data/lib/validatable/validations/validates_numericality_of.rb +27 -0
- data/lib/validatable/validations/validates_presence_of.rb +17 -0
- data/lib/validatable/validations/validates_true_for.rb +13 -0
- data/lib/validatable/validations/validation_base.rb +91 -0
- data/test/functional/test_validatable.rb +519 -0
- data/test/functional/test_validates_acceptance_of.rb +16 -0
- data/test/functional/test_validates_associated.rb +41 -0
- data/test/functional/test_validates_confirmation_of.rb +56 -0
- data/test/functional/test_validates_each.rb +14 -0
- data/test/functional/test_validates_exclusion_of.rb +29 -0
- data/test/functional/test_validates_format_of.rb +34 -0
- data/test/functional/test_validates_inclusion_of.rb +29 -0
- data/test/functional/test_validates_length_of.rb +64 -0
- data/test/functional/test_validates_numericality_of.rb +57 -0
- data/test/functional/test_validates_presence_of.rb +16 -0
- data/test/functional/test_validates_true_for.rb +27 -0
- data/test/test_helper.rb +33 -0
- data/test/unit/test_errors.rb +82 -0
- data/test/unit/test_understandable.rb +19 -0
- data/test/unit/test_validatable.rb +38 -0
- data/test/unit/test_validates_acceptance_of.rb +45 -0
- data/test/unit/test_validates_associated.rb +29 -0
- data/test/unit/test_validates_confirmation_of.rb +76 -0
- data/test/unit/test_validates_exclusion_of.rb +23 -0
- data/test/unit/test_validates_format_of.rb +44 -0
- data/test/unit/test_validates_inclusion_of.rb +23 -0
- data/test/unit/test_validates_length_of.rb +80 -0
- data/test/unit/test_validates_numericality_of.rb +76 -0
- data/test/unit/test_validates_presence_of.rb +35 -0
- data/test/unit/test_validates_true_for.rb +29 -0
- data/test/unit/test_validation_base.rb +52 -0
- metadata +133 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
|
5
|
+
expect false do
|
6
|
+
validation = Validatable::ValidatesPresenceOf.new stub_everything, :name
|
7
|
+
validation.valid?(stub_everything)
|
8
|
+
end
|
9
|
+
|
10
|
+
expect true do
|
11
|
+
validation = Validatable::ValidatesPresenceOf.new stub_everything, :name
|
12
|
+
validation.valid?(stub(:name=>"book"))
|
13
|
+
end
|
14
|
+
|
15
|
+
expect true do
|
16
|
+
validation = Validatable::ValidatesPresenceOf.new stub_everything, :name, :allow_nil => true
|
17
|
+
validation.valid?(stub(:name=>nil))
|
18
|
+
end
|
19
|
+
|
20
|
+
expect true do
|
21
|
+
validation = Validatable::ValidatesPresenceOf.new stub_everything, :name, :allow_blank => true
|
22
|
+
validation.valid?(stub(:name=>''))
|
23
|
+
end
|
24
|
+
|
25
|
+
expect true do
|
26
|
+
validation = Validatable::ValidatesPresenceOf.new stub_everything, :employee
|
27
|
+
validation.valid?(stub(:employee => stub(:nil? => false)))
|
28
|
+
end
|
29
|
+
|
30
|
+
expect true do
|
31
|
+
options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil}
|
32
|
+
Validatable::ValidatesPresenceOf.new(stub_everything, :test).must_understand(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
|
5
|
+
expect false do
|
6
|
+
validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { false }
|
7
|
+
validation.valid?(stub_everything)
|
8
|
+
end
|
9
|
+
|
10
|
+
expect true do
|
11
|
+
validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { true }
|
12
|
+
validation.valid?(stub_everything)
|
13
|
+
end
|
14
|
+
|
15
|
+
expect ArgumentError do
|
16
|
+
validation = Validatable::ValidatesTrueFor.new stub_everything, :age
|
17
|
+
end
|
18
|
+
|
19
|
+
expect true do
|
20
|
+
options = [:message, :if, :times, :level, :groups, :logic, :key]
|
21
|
+
Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).must_understand(options.to_blank_options_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
expect true do
|
25
|
+
options = [:logic]
|
26
|
+
Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).requires(options.to_blank_options_hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect true do
|
5
|
+
validation = Validatable::ValidationBase.new stub_everything, :base
|
6
|
+
validation.should_validate? Object.new
|
7
|
+
end
|
8
|
+
|
9
|
+
expect true do
|
10
|
+
validation = Validatable::ValidationBase.new stub_everything, :base, :times => 1
|
11
|
+
validation.validate_this_time?(stub(:times_validated => 0))
|
12
|
+
end
|
13
|
+
|
14
|
+
expect true do
|
15
|
+
validation = Validatable::ValidationBase.new stub_everything, :base
|
16
|
+
validation.validate_this_time?(nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
expect true do
|
20
|
+
validation = Validatable::ValidationBase.new stub_everything, :base, :times => 2
|
21
|
+
validation.validate_this_time?(stub(:times_validated => 1))
|
22
|
+
end
|
23
|
+
|
24
|
+
expect false do
|
25
|
+
validation = Validatable::ValidationBase.new stub_everything, :base, :times => 1
|
26
|
+
validation.validate_this_time?(stub(:times_validated => 1))
|
27
|
+
end
|
28
|
+
|
29
|
+
expect 1 do
|
30
|
+
validation = Validatable::ValidationBase.new stub_everything, :base
|
31
|
+
validation.level
|
32
|
+
end
|
33
|
+
|
34
|
+
expect ArgumentError do
|
35
|
+
Validatable::ValidationBase.new stub_everything(:validation_keys_include? => true), :base, :times => 1
|
36
|
+
end
|
37
|
+
|
38
|
+
expect "some message 100" do
|
39
|
+
validation = Validatable::ValidationBase.new stub_everything, :base, :message => lambda { "some message #{a_method}" }
|
40
|
+
validation.message(stub(:a_method=>'100'))
|
41
|
+
end
|
42
|
+
|
43
|
+
expect ArgumentError do
|
44
|
+
Validatable::ValidationBase.new(stub_everything, :base).must_understand(:foo => 1, :bar => 2)
|
45
|
+
end
|
46
|
+
|
47
|
+
expect true do
|
48
|
+
options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil, :key => nil}
|
49
|
+
Validatable::ValidationBase.new(stub_everything, :base).must_understand(options)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mattmatt-validatable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.8.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jay Fields
|
8
|
+
- John Nunemaker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-04-19 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: Validatable is a library for adding validations.
|
18
|
+
email: meyer@paperplanes.de
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- README.rdoc
|
27
|
+
- Rakefile
|
28
|
+
- VERSION.yml
|
29
|
+
- lib/validatable.rb
|
30
|
+
- lib/validatable/child_validation.rb
|
31
|
+
- lib/validatable/errors.rb
|
32
|
+
- lib/validatable/included_validation.rb
|
33
|
+
- lib/validatable/macros.rb
|
34
|
+
- lib/validatable/object_extension.rb
|
35
|
+
- lib/validatable/requireable.rb
|
36
|
+
- lib/validatable/understandable.rb
|
37
|
+
- lib/validatable/validatable_class_methods.rb
|
38
|
+
- lib/validatable/validatable_instance_methods.rb
|
39
|
+
- lib/validatable/validations/validates_acceptance_of.rb
|
40
|
+
- lib/validatable/validations/validates_associated.rb
|
41
|
+
- lib/validatable/validations/validates_confirmation_of.rb
|
42
|
+
- lib/validatable/validations/validates_each.rb
|
43
|
+
- lib/validatable/validations/validates_exclusion_of.rb
|
44
|
+
- lib/validatable/validations/validates_format_of.rb
|
45
|
+
- lib/validatable/validations/validates_inclusion_of.rb
|
46
|
+
- lib/validatable/validations/validates_length_of.rb
|
47
|
+
- lib/validatable/validations/validates_numericality_of.rb
|
48
|
+
- lib/validatable/validations/validates_presence_of.rb
|
49
|
+
- lib/validatable/validations/validates_true_for.rb
|
50
|
+
- lib/validatable/validations/validation_base.rb
|
51
|
+
- test/functional/test_validatable.rb
|
52
|
+
- test/functional/test_validates_acceptance_of.rb
|
53
|
+
- test/functional/test_validates_associated.rb
|
54
|
+
- test/functional/test_validates_confirmation_of.rb
|
55
|
+
- test/functional/test_validates_each.rb
|
56
|
+
- test/functional/test_validates_exclusion_of.rb
|
57
|
+
- test/functional/test_validates_format_of.rb
|
58
|
+
- test/functional/test_validates_inclusion_of.rb
|
59
|
+
- test/functional/test_validates_length_of.rb
|
60
|
+
- test/functional/test_validates_numericality_of.rb
|
61
|
+
- test/functional/test_validates_presence_of.rb
|
62
|
+
- test/functional/test_validates_true_for.rb
|
63
|
+
- test/test_helper.rb
|
64
|
+
- test/unit/test_errors.rb
|
65
|
+
- test/unit/test_understandable.rb
|
66
|
+
- test/unit/test_validatable.rb
|
67
|
+
- test/unit/test_validates_acceptance_of.rb
|
68
|
+
- test/unit/test_validates_associated.rb
|
69
|
+
- test/unit/test_validates_confirmation_of.rb
|
70
|
+
- test/unit/test_validates_exclusion_of.rb
|
71
|
+
- test/unit/test_validates_format_of.rb
|
72
|
+
- test/unit/test_validates_inclusion_of.rb
|
73
|
+
- test/unit/test_validates_length_of.rb
|
74
|
+
- test/unit/test_validates_numericality_of.rb
|
75
|
+
- test/unit/test_validates_presence_of.rb
|
76
|
+
- test/unit/test_validates_true_for.rb
|
77
|
+
- test/unit/test_validation_base.rb
|
78
|
+
has_rdoc: true
|
79
|
+
homepage: http://github.com/mattmatt/validatable
|
80
|
+
licenses: []
|
81
|
+
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options:
|
84
|
+
- --charset=UTF-8
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
version:
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.3.5
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Validatable is a library for adding validations.
|
106
|
+
test_files:
|
107
|
+
- test/functional/test_validatable.rb
|
108
|
+
- test/functional/test_validates_acceptance_of.rb
|
109
|
+
- test/functional/test_validates_associated.rb
|
110
|
+
- test/functional/test_validates_confirmation_of.rb
|
111
|
+
- test/functional/test_validates_each.rb
|
112
|
+
- test/functional/test_validates_exclusion_of.rb
|
113
|
+
- test/functional/test_validates_format_of.rb
|
114
|
+
- test/functional/test_validates_inclusion_of.rb
|
115
|
+
- test/functional/test_validates_length_of.rb
|
116
|
+
- test/functional/test_validates_numericality_of.rb
|
117
|
+
- test/functional/test_validates_presence_of.rb
|
118
|
+
- test/functional/test_validates_true_for.rb
|
119
|
+
- test/test_helper.rb
|
120
|
+
- test/unit/test_errors.rb
|
121
|
+
- test/unit/test_understandable.rb
|
122
|
+
- test/unit/test_validatable.rb
|
123
|
+
- test/unit/test_validates_acceptance_of.rb
|
124
|
+
- test/unit/test_validates_associated.rb
|
125
|
+
- test/unit/test_validates_confirmation_of.rb
|
126
|
+
- test/unit/test_validates_exclusion_of.rb
|
127
|
+
- test/unit/test_validates_format_of.rb
|
128
|
+
- test/unit/test_validates_inclusion_of.rb
|
129
|
+
- test/unit/test_validates_length_of.rb
|
130
|
+
- test/unit/test_validates_numericality_of.rb
|
131
|
+
- test/unit/test_validates_presence_of.rb
|
132
|
+
- test/unit/test_validates_true_for.rb
|
133
|
+
- test/unit/test_validation_base.rb
|