spectator-validates_email 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -6,41 +6,46 @@ validates_email is a Rails 3 plugin that validates email addresses against RFC 2
6
6
 
7
7
  rails plugin install git://github.com/spectator/validates_email.git
8
8
 
9
- or
9
+ or
10
10
 
11
11
  gem 'spectator-validates_email', :require => 'validates_email'
12
12
 
13
13
  == Usage
14
14
 
15
15
  class User < ActiveRecord::Base
16
- validates :field, :email => true
16
+ validates :primary_email, :email => true
17
17
  end
18
18
 
19
19
  As well as any other Rails 3 validation this one has the same triggers, such as <tt>:on</tt>, <tt>:if</tt>, <tt>:unless</tt>, <tt>:allow_blank</tt>, and <tt>:allow_nil</tt>.
20
20
 
21
- Also, you can pass your custom error message, otherwise it will use ActiveRecord's invalid error message.
21
+ Also, you can pass your own custom error message.
22
22
 
23
23
  class User < ActiveRecord::Base
24
- validates :field, :email => { :message => 'is not an email address' }
24
+ validates :primary_email, :email => { :message => 'is not an email address' }
25
25
  end
26
26
 
27
27
  If you like to check MX Records for email, you can use <tt>:mx</tt> option.
28
28
 
29
29
  class User < ActiveRecord::Base
30
- validates :field, :email => { :mx => true }
30
+ validates :primary_email, :email => { :mx => true }
31
31
  end
32
32
 
33
33
  And if you like to check MX Records with fallback to A record, use <tt>:a_fallback</tt> option.
34
34
 
35
35
  class User < ActiveRecord::Base
36
- validates :field, :email => { :mx => { :a_fallback => true } }
36
+ validates :primary_email, :email => { :mx => { :a_fallback => true } }
37
37
  end
38
38
 
39
- == Testing
39
+ == I18n
40
40
 
41
- To execute unit tests run <tt>rake test</tt> within plugin folder.
41
+ If you don't specify your own error message, then ActiveRecord's <tt>:invalid</tt> error message will be used to show the error.
42
42
 
43
- The unit tests for this plugin use an in-memory sqlite3 database.
43
+ If do check MX Records, then you have to specify your own error message or add it to your traslations:
44
+
45
+ activerecord:
46
+ errors:
47
+ messages:
48
+ mx_invalid: "is not valid"
44
49
 
45
50
  == Credits
46
51
 
@@ -48,9 +53,24 @@ Most of the code were taken from Alex Dunae (dunae.ca) plugin (see http://github
48
53
 
49
54
  == Contributors
50
55
 
51
- Petr Blaho
52
- Christian Eichhorn
56
+ * Petr Blaho
57
+ * Christian Eichhorn
58
+
59
+ == How to contribute
60
+
61
+ * Fork
62
+ * Make changes
63
+ * Write specs
64
+ * Do pull request
65
+
66
+ == Testing
67
+
68
+ To execute unit tests run <tt>rake spec</tt> within plugin folder.
69
+
70
+ The unit tests for this plugin use an in-memory sqlite3 database.
53
71
 
54
72
  == Notes
55
73
 
56
- Tested under ruby 1.9.2-rc1 and Rails 3 Edge
74
+ Compatible with following ruby versions:
75
+ * Ruby 1.8.7
76
+ * Ruby 1.9.2
@@ -1,43 +1 @@
1
- class EmailValidator < ActiveModel::EachValidator
2
-
3
- LocalPartSpecialChars = Regexp.escape('!#$%&\'*-/=?+-^_`{|}~')
4
- LocalPartUnquoted = '(([[:alnum:]' + LocalPartSpecialChars + ']+[\.\+]+))*[[:alnum:]' + LocalPartSpecialChars + '+]+'
5
- LocalPartQuoted = '\"(([[:alnum:]' + LocalPartSpecialChars + '\.\+]*|(\\\\[\x00-\xFF]))*)\"'
6
- Regex = Regexp.new('^((' + LocalPartUnquoted + ')|(' + LocalPartQuoted + ')+)@(((\w+\-+[^_])|(\w+\.[^_]))*([a-z0-9-]{1,63})\.[a-z]{2,6}$)', Regexp::EXTENDED | Regexp::IGNORECASE, 'n')
7
-
8
- def validates_email_format(email)
9
- # local part max is 64 chars, domain part max is 255 chars
10
- # TODO: should this decode escaped entities before counting?
11
- begin
12
- local, domain = email.split('@', 2)
13
- rescue NoMethodError
14
- return false
15
- end
16
-
17
- email =~ Regex and not email =~ /\.\./ and domain.length <= 255 and local.length <= 64
18
- end
19
-
20
- def validates_email_domain(email, options)
21
- require 'resolv'
22
- a_fallback = options.is_a?(Hash) ? options[:a_fallback] : false
23
- domain = email.match(/\@(.+)/)[1]
24
- Resolv::DNS.open do |dns|
25
- @mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
26
- @mx.push(*dns.getresources(domain, Resolv::DNS::Resource::IN::A)) if a_fallback
27
- end
28
- @mx.size > 0 ? true : false
29
- end
30
-
31
- def validate_each(record, attribute, value)
32
- if validates_email_format(value)
33
- # only test the mx if the email format is valid first
34
- # (missing @ raises exception in validates_email_domain)
35
- if options[:mx] && !validates_email_domain(value, options[:mx])
36
- record.errors[attribute] << (options[:mx_message] || I18n.t(:mx_invalid, :scope => [:activerecord, :errors, :messages]))
37
- end
38
- else
39
- record.errors[attribute] << (options[:message] || I18n.t(:invalid, :scope => [:activerecord, :errors, :messages]))
40
- end
41
- end
42
-
43
- end
1
+ require "validates_email/email_validator"
@@ -0,0 +1,69 @@
1
+ # Email validation class which uses Rails 3 ActiveModel
2
+ # validation mechanism.
3
+ #
4
+ class EmailValidator < ActiveModel::EachValidator
5
+
6
+ LocalPartSpecialChars = Regexp.escape('!#$%&\'*-/=?+-^_`{|}~')
7
+ LocalPartUnquoted = '(([[:alnum:]' + LocalPartSpecialChars + ']+[\.\+]+))*[[:alnum:]' + LocalPartSpecialChars + '+]+'
8
+ LocalPartQuoted = '\"(([[:alnum:]' + LocalPartSpecialChars + '\.\+]*|(\\\\[\x00-\xFF]))*)\"'
9
+ Regex = Regexp.new('^((' + LocalPartUnquoted + ')|(' + LocalPartQuoted + ')+)@(((\w+\-+[^_])|(\w+\.[^_]))*([a-z0-9-]{1,63})\.[a-z]{2,6}$)', Regexp::EXTENDED | Regexp::IGNORECASE, 'n')
10
+
11
+ # Validates email address.
12
+ # If MX fallback was also requested, it will check if email is valid
13
+ # first, and only after that will go to MX fallback.
14
+ #
15
+ # @example
16
+ # class User < ActiveRecord::Base
17
+ # validates :primary_email, :email => { :mx => { :a_fallback => true } }
18
+ # end
19
+ #
20
+ def validate_each(record, attribute, value)
21
+ if validates_email_format(value)
22
+ if options[:mx] && !validates_email_domain(value, options[:mx])
23
+ record.errors[attribute] << (options[:mx_message] || I18n.t(:mx_invalid, :scope => [:activerecord, :errors, :messages]))
24
+ end
25
+ else
26
+ record.errors[attribute] << (options[:message] || I18n.t(:invalid, :scope => [:activerecord, :errors, :messages]))
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ # Checks email if it's valid by rules defined in `Regex`.
33
+ #
34
+ # @param [String] A string with email. Local part of email is max 64 chars,
35
+ # domain part is max 255 chars.
36
+ #
37
+ # @return [Boolean] True or false.
38
+ #
39
+ def validates_email_format(email)
40
+ # TODO: should this decode escaped entities before counting?
41
+ begin
42
+ local, domain = email.split('@', 2)
43
+ rescue NoMethodError
44
+ return false
45
+ end
46
+
47
+ email =~ Regex and not email =~ /\.\./ and domain.length <= 255 and local.length <= 64
48
+ end
49
+
50
+ # Checks email is its domain is valid. Fallbacks to A record if requested.
51
+ #
52
+ # @param [String] A string with email.
53
+ # @param [Hash] A hash of options, which tells whether to use A fallback or
54
+ # or not. Additional options can be also passed.
55
+ #
56
+ # @return [Integer, nil] In general, it's true or false.
57
+ #
58
+ def validates_email_domain(email, options)
59
+ require 'resolv'
60
+ a_fallback = options.is_a?(Hash) ? options[:a_fallback] : false
61
+ domain = email.match(/\@(.+)/)[1]
62
+ Resolv::DNS.open do |dns|
63
+ @mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
64
+ @mx.push(*dns.getresources(domain, Resolv::DNS::Resource::IN::A)) if a_fallback
65
+ end
66
+ @mx.size > 0 ? true : false
67
+ end
68
+
69
+ end
@@ -0,0 +1,3 @@
1
+ module ValidatesEmail
2
+ VERSION = "0.0.4"
3
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectator-validates_email
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Yury Velikanau
@@ -14,84 +15,111 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-10-24 00:00:00 -07:00
18
+ date: 2010-11-07 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: activerecord
22
+ name: actionpack
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
29
+ hash: 7
28
30
  segments:
29
31
  - 3
30
32
  - 0
31
33
  - 0
32
- - beta
33
- version: 3.0.0.beta
34
- type: :development
34
+ version: 3.0.0
35
+ type: :runtime
35
36
  version_requirements: *id001
36
37
  - !ruby/object:Gem::Dependency
37
- name: activesupport
38
+ name: activemodel
38
39
  prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
43
  - - ~>
43
44
  - !ruby/object:Gem::Version
45
+ hash: 7
44
46
  segments:
45
47
  - 3
46
48
  - 0
47
49
  - 0
48
- - beta
49
- version: 3.0.0.beta
50
- type: :development
50
+ version: 3.0.0
51
+ type: :runtime
51
52
  version_requirements: *id002
52
53
  - !ruby/object:Gem::Dependency
53
- name: sqlite3-ruby
54
+ name: bundler
54
55
  prerelease: false
55
56
  requirement: &id003 !ruby/object:Gem::Requirement
56
57
  none: false
57
58
  requirements:
58
59
  - - ~>
59
60
  - !ruby/object:Gem::Version
61
+ hash: 23
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 0
66
+ version: 1.0.0
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 15
78
+ segments:
79
+ - 2
80
+ - 0
81
+ - 0
82
+ version: 2.0.0
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: sqlite3-ruby
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 25
60
94
  segments:
61
95
  - 1
62
96
  - 3
63
97
  - 1
64
98
  version: 1.3.1
65
99
  type: :development
66
- version_requirements: *id003
67
- description: validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696
68
- email: yury.velikanau@gmail.com
100
+ version_requirements: *id005
101
+ description: Rails 3 plugin to validate email addresses against RFC 2822 and RFC 3696
102
+ email:
103
+ - yury.velikanau@gmail.com
69
104
  executables: []
70
105
 
71
106
  extensions: []
72
107
 
73
- extra_rdoc_files:
74
- - README.rdoc
108
+ extra_rdoc_files: []
109
+
75
110
  files:
76
- - .gitignore
111
+ - lib/validates_email/email_validator.rb
112
+ - lib/validates_email/version.rb
113
+ - lib/validates_email.rb
77
114
  - MIT-LICENSE
78
115
  - README.rdoc
79
- - Rakefile
80
- - VERSION
81
- - init.rb
82
- - lib/validates_email.rb
83
- - test/database.yml
84
- - test/schema.rb
85
- - test/test_helper.rb
86
- - test/validates_email_test.rb
87
- - validates_email.gemspec
88
116
  has_rdoc: true
89
117
  homepage: http://github.com/spectator/validates_email
90
118
  licenses: []
91
119
 
92
120
  post_install_message:
93
- rdoc_options:
94
- - --charset=UTF-8
121
+ rdoc_options: []
122
+
95
123
  require_paths:
96
124
  - lib
97
125
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -99,6 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
127
  requirements:
100
128
  - - ">="
101
129
  - !ruby/object:Gem::Version
130
+ hash: 3
102
131
  segments:
103
132
  - 0
104
133
  version: "0"
@@ -107,17 +136,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
136
  requirements:
108
137
  - - ">="
109
138
  - !ruby/object:Gem::Version
139
+ hash: 23
110
140
  segments:
111
- - 0
112
- version: "0"
141
+ - 1
142
+ - 3
143
+ - 6
144
+ version: 1.3.6
113
145
  requirements: []
114
146
 
115
147
  rubyforge_project:
116
148
  rubygems_version: 1.3.7
117
149
  signing_key:
118
150
  specification_version: 3
119
- summary: Gem to validate email addresses for Rails 3
120
- test_files:
121
- - test/schema.rb
122
- - test/test_helper.rb
123
- - test/validates_email_test.rb
151
+ summary: Rails 3 plugin to validate email addresses
152
+ test_files: []
153
+
data/.gitignore DELETED
@@ -1,15 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## PROJECT::GENERAL
9
- .rvmrc
10
- pkg
11
- rdoc
12
- *.gem
13
-
14
- ## PROJECT::SPECIFIC
15
- test/debug.log
data/Rakefile DELETED
@@ -1,41 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "spectator-validates_email"
8
- gem.summary = %Q{Gem to validate email addresses for Rails 3}
9
- gem.description = %Q{validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696}
10
- gem.email = "yury.velikanau@gmail.com"
11
- gem.homepage = "http://github.com/spectator/validates_email"
12
- gem.authors = ["Yury Velikanau"]
13
- gem.add_development_dependency "activerecord", "~> 3.0.0.beta"
14
- gem.add_development_dependency "activesupport", "~> 3.0.0.beta"
15
- gem.add_development_dependency "sqlite3-ruby", "~> 1.3.1"
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
- require 'rake/testtask'
23
- Rake::TestTask.new(:test) do |t|
24
- t.libs << 'lib'
25
- t.libs << 'test'
26
- t.pattern = 'test/**/*_test.rb'
27
- t.verbose = true
28
- end
29
-
30
- task :test => :check_dependencies
31
-
32
- task :default => :test
33
-
34
- require 'rake/rdoctask'
35
- Rake::RDocTask.new(:rdoc) do |rdoc|
36
- rdoc.rdoc_dir = 'rdoc'
37
- rdoc.title = 'ValidatesEmail'
38
- rdoc.options << '--line-numbers' << '--inline-source'
39
- rdoc.rdoc_files.include('README')
40
- rdoc.rdoc_files.include('lib/**/*.rb')
41
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.3
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'validates_email'
data/test/database.yml DELETED
@@ -1,3 +0,0 @@
1
- plugin_test:
2
- adapter: sqlite3
3
- database: ":memory:"
data/test/schema.rb DELETED
@@ -1,13 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 0) do
2
- create_table :people, :force => true do |t|
3
- t.string :email
4
- end
5
-
6
- create_table :mx_records, :force => true do |t|
7
- t.string :email
8
- end
9
-
10
- create_table :mx_fallbacks, :force => true do |t|
11
- t.string :email
12
- end
13
- end
data/test/test_helper.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'active_record'
4
- require 'active_support/core_ext/logger'
5
-
6
- def load_schema
7
- config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
8
- ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
9
-
10
- ActiveRecord::Base.establish_connection(config['plugin_test'])
11
- load(File.dirname(__FILE__) + "/schema.rb")
12
- require File.dirname(__FILE__) + '/../init.rb'
13
- end
@@ -1,165 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ValidatesEmailTest < ActiveSupport::TestCase
4
- load_schema
5
-
6
- class Person < ActiveRecord::Base
7
- validates :email, :email => { :message => 'fails with custom message' }
8
- end
9
-
10
- class MxRecord < ActiveRecord::Base
11
- validates :email, :email => { :mx => true,
12
- :mx_message => 'fails with custom mx message' }
13
- end
14
-
15
- class MxFallback < ActiveRecord::Base
16
- validates :email, :email => { :mx => { :a_fallback => true },
17
- :mx_message => 'fails with custom mx message' }
18
- end
19
-
20
- def test_should_allow_valid_email_addresses
21
- [
22
- 'valid@example.com',
23
- 'Valid@test.example.com',
24
- 'valid+valid123@test.example.com',
25
- 'valid_valid123@test.example.com',
26
- 'valid-valid+123@test.example.co.uk',
27
- 'valid-valid+1.23@test.example.com.au',
28
- 'valid@example.co.uk',
29
- 'v@example.com',
30
- 'valid@example.ca',
31
- 'valid_@example.com',
32
- 'valid123.456@example.org',
33
- 'valid123.456@example.travel',
34
- 'valid123.456@example.museum',
35
- 'valid@example.mobi',
36
- 'valid@example.info',
37
- 'valid-@example.com',
38
- # from RFC 3696, page 6
39
- 'customer/department=shipping@example.com',
40
- '$A12345@example.com',
41
- '!def!xyz%abc@example.com',
42
- '_somename@example.com',
43
- # apostrophes
44
- "test'test@example.com"
45
- ].each do |email|
46
- p = create_person(:email => email)
47
- save_passes(p, email)
48
- end
49
- end
50
-
51
- def test_should_not_allow_invalid_email_addresses
52
- [
53
- 'invalid@example-com',
54
- # period can not start local part
55
- '.invalid@example.com',
56
- # period can not end local part
57
- 'invalid.@example.com',
58
- # period can not appear twice consecutively in local part
59
- 'invali..d@example.com',
60
- # should not allow underscores in domain names
61
- 'invalid@ex_mple.com',
62
- 'invalid@example.com.',
63
- 'invalid@example.com_',
64
- 'invalid@example.com-',
65
- 'invalid-example.com',
66
- 'invalid@example.b#r.com',
67
- 'invalid@example.c',
68
- 'invali d@example.com',
69
- 'invalidexample.com',
70
- 'invalid@example.'
71
- ].each do |email|
72
- p = create_person(:email => email)
73
- save_fails(p, email)
74
- end
75
- end
76
-
77
- # from http://www.rfc-editor.org/errata_search.php?rfc=3696
78
- def test_should_allow_quoted_characters
79
- [
80
- '"Abc\@def"@example.com',
81
- '"Fred\ Bloggs"@example.com',
82
- '"Joe.\\Blow"@example.com'
83
- ].each do |email|
84
- p = create_person(:email => email)
85
- save_passes(p, email)
86
- end
87
- end
88
-
89
- # from http://tools.ietf.org/html/rfc3696, page 5
90
- # corrected in http://www.rfc-editor.org/errata_search.php?rfc=3696
91
- def test_should_not_allow_escaped_characters_without_quotes
92
- [
93
- 'Fred\ Bloggs_@example.com',
94
- 'Abc\@def+@example.com',
95
- 'Joe.\\Blow@example.com'
96
- ].each do |email|
97
- p = create_person(:email => email)
98
- save_fails(p, email)
99
- end
100
- end
101
-
102
- def test_should_check_length_limits
103
- [
104
- 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com',
105
- 'test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com'
106
- ].each do |email|
107
- p = create_person(:email => email)
108
- save_fails(p, email)
109
- end
110
- end
111
-
112
- def test_should_allow_custom_error_message
113
- p = create_person(:email => @invalid_email)
114
- save_fails(p)
115
- # Object.errors[:field] returns array now
116
- assert_equal ['fails with custom message'], p.errors[:email]
117
- end
118
-
119
- def test_should_validate_email_with_mx
120
- valid_email = 'test@gmail.com'
121
- p = MxRecord.new(:email => valid_email)
122
- save_passes(p, valid_email)
123
-
124
- invalid_email = 'test@example.com'
125
- p = MxRecord.new(:email => invalid_email)
126
- save_fails(p, invalid_email)
127
- end
128
-
129
- def test_should_validate_with_mx_fallback
130
- valid_email = 'test@gmail.com'
131
- p = MxFallback.new(:email => valid_email)
132
- save_passes(p, valid_email)
133
-
134
- invalid_email = 'test@example.com'
135
- p = MxFallback.new(:email => invalid_email)
136
- save_passes(p, invalid_email)
137
- end
138
-
139
- def test_should_not_validate_mx_with_invalid_email
140
- invalid_email = 'testexample.com'
141
- assert_nothing_raised do
142
- p = MxFallback.new(:email => invalid_email)
143
- save_fails(p, invalid_email)
144
- end
145
- end
146
-
147
- protected
148
-
149
- def create_person(params)
150
- Person.new(params)
151
- end
152
-
153
- def save_passes(p, email = '')
154
- assert p.valid?, " validating #{email}"
155
- assert p.save
156
- assert_empty p.errors[:email]
157
- end
158
-
159
- def save_fails(p, email = '')
160
- assert !p.valid?, " validating #{email}"
161
- assert !p.save
162
- assert_not_empty p.errors[:email]
163
- end
164
-
165
- end
@@ -1,62 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{spectator-validates_email}
8
- s.version = "0.0.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Yury Velikanau"]
12
- s.date = %q{2010-10-24}
13
- s.description = %q{validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696}
14
- s.email = %q{yury.velikanau@gmail.com}
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION",
24
- "init.rb",
25
- "lib/validates_email.rb",
26
- "test/database.yml",
27
- "test/schema.rb",
28
- "test/test_helper.rb",
29
- "test/validates_email_test.rb",
30
- "validates_email.gemspec"
31
- ]
32
- s.homepage = %q{http://github.com/spectator/validates_email}
33
- s.rdoc_options = ["--charset=UTF-8"]
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.7}
36
- s.summary = %q{Gem to validate email addresses for Rails 3}
37
- s.test_files = [
38
- "test/schema.rb",
39
- "test/test_helper.rb",
40
- "test/validates_email_test.rb"
41
- ]
42
-
43
- if s.respond_to? :specification_version then
44
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
- s.specification_version = 3
46
-
47
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<activerecord>, ["~> 3.0.0.beta"])
49
- s.add_development_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
50
- s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
51
- else
52
- s.add_dependency(%q<activerecord>, ["~> 3.0.0.beta"])
53
- s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
54
- s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
55
- end
56
- else
57
- s.add_dependency(%q<activerecord>, ["~> 3.0.0.beta"])
58
- s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
59
- s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.1"])
60
- end
61
- end
62
-