validator_attachment 1.0.1 → 1.0.2
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/CHANGELOG +2 -0
- data/README.rdoc +7 -7
- data/Rakefile +2 -2
- data/validator_attachment.gemspec +8 -8
- metadata +10 -8
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -15,11 +15,11 @@ Assuming that you have a Model like the following:
|
|
15
15
|
In your test:
|
16
16
|
|
17
17
|
test "last name has to be present" do
|
18
|
-
assert ActiveModel::PresenceValidator.is_attached?(MyAwesomeModel, :last_name)
|
18
|
+
assert ActiveModel::Validations::PresenceValidator.is_attached?(MyAwesomeModel, :last_name)
|
19
19
|
end
|
20
20
|
|
21
21
|
will test that your +last_name+ attribute on the model +MyAwesomeModel+ has a +:presence+ validation attached. Note
|
22
|
-
that +ActiveModel+::+PresenceValidator+ is the +class+ that comes with Rails +ActiveModel+.
|
22
|
+
that +ActiveModel+::+Validations+::+PresenceValidator+ is the +class+ that comes with Rails +ActiveModel+.
|
23
23
|
|
24
24
|
Optionally, you can also check whether the correct options are attached too. So, if you have a Model like:
|
25
25
|
|
@@ -31,15 +31,15 @@ In your test:
|
|
31
31
|
|
32
32
|
test "last name should not be of correct length" do
|
33
33
|
# you do not have to check for all options
|
34
|
-
assert ActiveModel::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :minimum => 3 })
|
35
|
-
assert ActiveModel::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :maximum => 60 })
|
34
|
+
assert ActiveModel::Validations::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :minimum => 3 })
|
35
|
+
assert ActiveModel::Validations::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :maximum => 60 })
|
36
36
|
|
37
37
|
# or you can check for all
|
38
|
-
assert ActiveModel::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :minimum => 3, :maximum => 60 })
|
38
|
+
assert ActiveModel::Validations::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :minimum => 3, :maximum => 60 })
|
39
39
|
|
40
40
|
# or you can ask for those and only those, i.e. exact content match
|
41
|
-
assert !ActiveModel::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :maximum => 60 }, true)
|
42
|
-
assert ActiveModel::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :minimum > 60, :maximum => 60 }, true)
|
41
|
+
assert !ActiveModel::Validations::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :maximum => 60 }, true)
|
42
|
+
assert ActiveModel::Validations::LengthValidator.is_attached?(MyAwesomeModel, :last_name, { :minimum > 60, :maximum => 60 }, true)
|
43
43
|
end
|
44
44
|
|
45
45
|
Another example with +with_options+:
|
data/Rakefile
CHANGED
@@ -11,8 +11,8 @@ Echoe.new('validator_attachment') do |p|
|
|
11
11
|
p.email = "panayotis@matsinopoulos.gr"
|
12
12
|
p.ignore_pattern = ["tmp/*", "script/*", "rdoc_output/*", "rdoc_output/js/*", "rdoc_output/images/*", "rdoc_output/ActiveModel/*", "rdoc_output/lib/*",
|
13
13
|
"yard_output/*", "yard_output/js/*", "yard_output/css/*", "Gemfile", "Gemfile.lock", "*.iml"]
|
14
|
-
p.runtime_dependencies = ["rails
|
15
|
-
p.development_dependencies = ["rails
|
14
|
+
p.runtime_dependencies = ["rails ~>3.0.0"]
|
15
|
+
p.development_dependencies = ["rails ~>3.0.0", "ruby-debug", 'ruby-debug-ide', 'ruby-debug-base']
|
16
16
|
end
|
17
17
|
|
18
18
|
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each{ |ext| load ext }
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{validator_attachment}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [%q{Panayotis Matsinopoulos}]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2012-01-19}
|
10
10
|
s.description = %q{Checks whether an ActiveModel Validator is attached to an attribute of a Model and with which options}
|
11
11
|
s.email = %q{panayotis@matsinopoulos.gr}
|
12
12
|
s.extra_rdoc_files = [%q{CHANGELOG}, %q{README.rdoc}, %q{lib/validator_attachment.rb}]
|
@@ -23,21 +23,21 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.specification_version = 3
|
24
24
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_runtime_dependency(%q<rails>, ["
|
27
|
-
s.add_development_dependency(%q<rails>, ["
|
26
|
+
s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
|
27
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.0"])
|
28
28
|
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
29
29
|
s.add_development_dependency(%q<ruby-debug-ide>, [">= 0"])
|
30
30
|
s.add_development_dependency(%q<ruby-debug-base>, [">= 0"])
|
31
31
|
else
|
32
|
-
s.add_dependency(%q<rails>, ["
|
33
|
-
s.add_dependency(%q<rails>, ["
|
32
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
33
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
34
34
|
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
35
35
|
s.add_dependency(%q<ruby-debug-ide>, [">= 0"])
|
36
36
|
s.add_dependency(%q<ruby-debug-base>, [">= 0"])
|
37
37
|
end
|
38
38
|
else
|
39
|
-
s.add_dependency(%q<rails>, ["
|
40
|
-
s.add_dependency(%q<rails>, ["
|
39
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
40
|
+
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
41
41
|
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
42
42
|
s.add_dependency(%q<ruby-debug-ide>, [">= 0"])
|
43
43
|
s.add_dependency(%q<ruby-debug-base>, [">= 0"])
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validator_attachment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Panayotis Matsinopoulos
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
@@ -23,13 +23,14 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
hash: 7
|
29
29
|
segments:
|
30
30
|
- 3
|
31
31
|
- 0
|
32
|
-
|
32
|
+
- 0
|
33
|
+
version: 3.0.0
|
33
34
|
type: :runtime
|
34
35
|
version_requirements: *id001
|
35
36
|
- !ruby/object:Gem::Dependency
|
@@ -38,13 +39,14 @@ dependencies:
|
|
38
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
|
-
- -
|
42
|
+
- - ~>
|
42
43
|
- !ruby/object:Gem::Version
|
43
44
|
hash: 7
|
44
45
|
segments:
|
45
46
|
- 3
|
46
47
|
- 0
|
47
|
-
|
48
|
+
- 0
|
49
|
+
version: 3.0.0
|
48
50
|
type: :development
|
49
51
|
version_requirements: *id002
|
50
52
|
- !ruby/object:Gem::Dependency
|