valid_email 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42a2f72cc8d27b8f7bfa7cc975a7b06512f6cbac
4
- data.tar.gz: 6e6a23102e9b365aa96da9ce632dc8b890f15753
3
+ metadata.gz: c545251c17d33f29c1cc777e798aa7a08937af43
4
+ data.tar.gz: 78da306fab1e3a75633be0cb25c7430d809e0361
5
5
  SHA512:
6
- metadata.gz: 3918c4f4a86617449a70451e7f914874972dcb7045beead234ddbfac21b69e84e269e21122ba1e2b433bbadc0d362815f6f0e91dbc34eb1c860af7b53164dc10
7
- data.tar.gz: 907854ee62fcc7474d225ab1c87b526b1c688c61f58b40c79023bf84e8b61b13a23dd0b692b03df5886affbe7c82e0d18be0241905ef85148bd58d540afdfa97
6
+ metadata.gz: 48566bddaff58f5d006f3b398a39ca3713902805eec7ef69fcc9fe0b6a7451aaf40fc457627e568a973336559a171c6ad2f98732e1806e9cc88e943334000d68
7
+ data.tar.gz: 41fd65d81b424fbbbb566f8f94e9be28f435afeca997fe49f4409508b76136a1fab068100181adb0e0998d1a0fd99ee199f76c9a07f9936fdaac95377a1128d9
data/README.md CHANGED
@@ -32,7 +32,7 @@ In your code :
32
32
  p.email = "John Does <john@doe.com>"
33
33
  p.valid? # => false
34
34
 
35
- You can check if email domain has MX record :
35
+ You can check if email domain has MX record:
36
36
 
37
37
  validates :email, :email => {:mx => true, :message => I18n.t('validations.errors.models.user.invalid_email')}
38
38
 
@@ -40,6 +40,10 @@ Or
40
40
 
41
41
  validates :email, :email => {:message => I18n.t('validations.errors.models.user.invalid_email')}, :mx => {:message => I18n.t('validations.errors.models.user.invalid_mx')}
42
42
 
43
+ You can check if the email domain looks valid. This uses a regular expression so no external services are required, which improves the performance of this check:
44
+
45
+ validates :email, :email => {:domain => true}
46
+
43
47
  Alternatively, you can check if an email domain has a MX or A record by using `:mx_with_fallback` instead of `:mx`.
44
48
 
45
49
  You can detect disposable accounts
@@ -0,0 +1,5 @@
1
+ hu:
2
+ valid_email:
3
+ validations:
4
+ email:
5
+ invalid: "érvénytelen email cím"
@@ -0,0 +1,5 @@
1
+ ja:
2
+ valid_email:
3
+ validations:
4
+ email:
5
+ invalid: "不正な値です"
@@ -0,0 +1,5 @@
1
+ uk:
2
+ valid_email:
3
+ validations:
4
+ email:
5
+ invalid: "неправильний формат"
@@ -44,6 +44,7 @@ disposable_email_services:
44
44
  - a-bc.net
45
45
  - afrobacon.com
46
46
  - ajaxapp.net
47
+ - amail4.me
47
48
  - amilegit.com
48
49
  - amiri.net
49
50
  - amiriindustries.com
@@ -254,6 +255,9 @@ disposable_email_services:
254
255
  - mailexpire.com
255
256
  - mailfa.tk
256
257
  - mailfreeonline.com
258
+ - mailhazard.com
259
+ - mailhazard.us
260
+ - mailhz.me
257
261
  - mailin8r.com
258
262
  - mailinater.com
259
263
  - mailinator.com
@@ -512,6 +516,8 @@ disposable_email_services:
512
516
  - yopmail.net
513
517
  - ypmail.webarnak.fr.eu.org
514
518
  - yuurok.com
519
+ - zebins.com
520
+ - zebins.eu
515
521
  - zehnminutenmail.de
516
522
  - zippymail.info
517
523
  - zoaxe.com
@@ -3,3 +3,4 @@ require 'valid_email/email_validator'
3
3
  require 'valid_email/mx_validator'
4
4
  require 'valid_email/mx_with_fallback_validator'
5
5
  require 'valid_email/ban_disposable_email_validator'
6
+ require 'valid_email/domain_validator'
@@ -1,6 +1,5 @@
1
1
  require 'active_model'
2
2
  require 'active_model/validations'
3
- require 'mail'
4
3
  require 'valid_email/validate_email'
5
4
  class BanDisposableEmailValidator < ActiveModel::EachValidator
6
5
  # A list of disposable email domains
@@ -0,0 +1,13 @@
1
+ require 'active_model'
2
+ require 'active_model/validations'
3
+ require 'valid_email/validate_email'
4
+
5
+ class DomainValidator < ActiveModel::EachValidator
6
+ def validate_each(record, attribute, value)
7
+ r = ValidateEmail.domain_valid?(value)
8
+ record.errors.add attribute, (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email")) unless r
9
+
10
+ r
11
+ end
12
+ end
13
+
@@ -1,6 +1,5 @@
1
1
  require 'active_model'
2
2
  require 'active_model/validations'
3
- require 'mail'
4
3
  require 'valid_email/validate_email'
5
4
  class EmailValidator < ActiveModel::EachValidator
6
5
  def validate_each(record,attribute,value)
@@ -21,6 +20,9 @@ class EmailValidator < ActiveModel::EachValidator
21
20
  require 'valid_email/ban_disposable_email_validator'
22
21
  r = BanDisposableEmailValidator.new(:attributes => attributes).validate(record)
23
22
  end
24
- record.errors.add attribute, (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email")) unless r
23
+ unless r
24
+ msg = (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email"))
25
+ record.errors.add attribute, (msg % {value: value})
26
+ end
25
27
  end
26
28
  end
@@ -1,6 +1,5 @@
1
1
  require 'active_model'
2
2
  require 'active_model/validations'
3
- require 'mail'
4
3
  require 'resolv'
5
4
  require 'valid_email/validate_email'
6
5
  class MxValidator < ActiveModel::EachValidator
@@ -1,11 +1,18 @@
1
+ require 'mail'
2
+
1
3
  class ValidateEmail
2
4
  class << self
3
5
  SPECIAL_CHARS = %w(( ) , : ; < > @ [ ])
4
6
  SPECIAL_ESCAPED_CHARS = %w(\ \\ ")
5
7
  LOCAL_MAX_LEN = 64
8
+ DOMAIN_REGEX = /\A^([[:alpha:]]{1}|([[:alnum:]][a-zA-Z0-9-]{0,61}[[:alnum:]]))(\.([[:alnum:]][a-zA-Z0-9-]{0,61}[[:alnum:]]))+\z/
6
9
 
7
10
  def valid?(value, user_options={})
8
- options = { :mx => false, :message => nil }.merge(user_options)
11
+ options = {
12
+ :mx => false,
13
+ :domain => false,
14
+ :message => nil
15
+ }.merge(user_options)
9
16
 
10
17
  m = Mail::Address.new(value)
11
18
  # We must check that value contains a domain and that value is an email address
@@ -20,7 +27,7 @@ class ValidateEmail
20
27
  return false unless m.domain.match(/^\S+$/)
21
28
 
22
29
  domain_dot_elements = m.domain.split(/\./)
23
- return false unless domain_dot_elements.size > 1 && domain_dot_elements.all?(&:present?)
30
+ return false unless domain_dot_elements.size > 1 && !domain_dot_elements.any?(&:empty?)
24
31
 
25
32
  # Ensure that the local segment adheres to adheres to RFC-5322
26
33
  return false unless valid_local?(m.local)
@@ -31,9 +38,20 @@ class ValidateEmail
31
38
  return mx_valid?(value)
32
39
  end
33
40
 
41
+ if options[:domain]
42
+ require 'valid_email/domain_validator'
43
+ return domain_valid?(value)
44
+ end
45
+
34
46
  true
35
47
  rescue Mail::Field::ParseError
36
48
  false
49
+ rescue ArgumentError => error
50
+ if error.message == 'bad value for range'
51
+ false
52
+ else
53
+ raise error
54
+ end
37
55
  end
38
56
 
39
57
  def valid_local?(local)
@@ -65,7 +83,7 @@ class ValidateEmail
65
83
  # If we're not in a quoted dot atom then no special characters are allowed.
66
84
  return false unless ((SPECIAL_CHARS | SPECIAL_ESCAPED_CHARS) & dot_atom.split('')).empty?
67
85
  end
68
- return true
86
+ return true
69
87
  end
70
88
 
71
89
  def mx_valid?(value, fallback=false)
@@ -87,6 +105,13 @@ class ValidateEmail
87
105
  mx_valid?(value, true)
88
106
  end
89
107
 
108
+ def domain_valid?(value)
109
+ m = Mail::Address.new(value)
110
+ return false unless m.domain
111
+
112
+ !(m.domain =~ DOMAIN_REGEX).nil?
113
+ end
114
+
90
115
  def ban_disposable_email?(value)
91
116
  m = Mail::Address.new(value)
92
117
  m.domain && !BanDisposableEmailValidator.config.include?(m.domain)
@@ -1 +1 @@
1
- ValidEmailVersion = "0.0.11"
1
+ ValidEmailVersion = "0.0.12"
@@ -49,11 +49,17 @@ describe EmailValidator do
49
49
  validates :email, :mx_with_fallback => true
50
50
  end
51
51
 
52
+ person_class_domain = Class.new do
53
+ include ActiveModel::Validations
54
+ attr_accessor :email
55
+ validates :email, :domain => true
56
+ end
57
+
52
58
  shared_examples_for "Invalid model" do
53
59
  before { subject.valid? }
54
60
 
55
- it { should_not be_valid }
56
- specify { subject.errors[:email].should =~ errors }
61
+ it { is_expected.not_to be_valid }
62
+ specify { expect(subject.errors[:email]).to match_array errors }
57
63
  end
58
64
 
59
65
  shared_examples_for "Validating emails" do
@@ -65,57 +71,57 @@ describe EmailValidator do
65
71
  describe "validating email" do
66
72
  subject { person_class.new }
67
73
 
68
- it "should fail when email empty" do
69
- subject.valid?.should be_falsey
70
- subject.errors[:email].should == errors
74
+ it "fails when email empty" do
75
+ expect(subject.valid?).to be_falsey
76
+ expect(subject.errors[:email]).to eq errors
71
77
  end
72
78
 
73
- it "should fail when email is not valid" do
79
+ it "fails when email is not valid" do
74
80
  subject.email = 'joh@doe'
75
- subject.valid?.should be_falsey
76
- subject.errors[:email].should == errors
81
+ expect(subject.valid?).to be_falsey
82
+ expect(subject.errors[:email]).to eq errors
77
83
  end
78
84
 
79
- it "should fail when email domain is prefixed with dot" do
85
+ it "fails when email domain is prefixed with dot" do
80
86
  subject.email = 'john@.doe'
81
- subject.valid?.should be_falsey
82
- subject.errors[:email].should == errors
87
+ expect(subject.valid?).to be_falsey
88
+ expect(subject.errors[:email]).to eq errors
83
89
  end
84
90
 
85
- it "should fail when email domain contains two consecutive dots" do
91
+ it "fails when email domain contains two consecutive dots" do
86
92
  subject.email = 'john@doe-two..com'
87
- subject.valid?.should be_falsey
88
- subject.errors[:email].should == errors
93
+ expect(subject.valid?).to be_falsey
94
+ expect(subject.errors[:email]).to eq errors
89
95
  end
90
96
 
91
- it "should fail when email is valid with information" do
97
+ it "fails when email is valid with information" do
92
98
  subject.email = '"John Doe" <john@doe.com>'
93
- subject.valid?.should be_falsey
94
- subject.errors[:email].should == errors
99
+ expect(subject.valid?).to be_falsey
100
+ expect(subject.errors[:email]).to eq errors
95
101
  end
96
102
 
97
- it "should pass when email is simple email address" do
103
+ it "passes when email is simple email address" do
98
104
  subject.email = 'john@doe.com'
99
- subject.valid?.should be_truthy
100
- subject.errors[:email].should be_empty
105
+ expect(subject.valid?).to be_truthy
106
+ expect(subject.errors[:email]).to be_empty
101
107
  end
102
108
 
103
- it "should fail when email is simple email address not stripped" do
109
+ it "fails when email is simple email address not stripped" do
104
110
  subject.email = 'john@doe.com '
105
- subject.valid?.should be_falsey
106
- subject.errors[:email].should == errors
111
+ expect(subject.valid?).to be_falsey
112
+ expect(subject.errors[:email]).to eq errors
107
113
  end
108
114
 
109
- it "should fail when domain contains a space" do
115
+ it "fails when domain contains a space" do
110
116
  subject.email = 'john@doe .com'
111
- subject.valid?.should be_falsey
112
- subject.errors[:email].should == errors
117
+ expect(subject.valid?).to be_falsey
118
+ expect(subject.errors[:email]).to eq errors
113
119
  end
114
120
 
115
- it "should fail when passing multiple simple email addresses" do
121
+ it "fails when passing multiple simple email addresses" do
116
122
  subject.email = 'john@doe.com, maria@doe.com'
117
- subject.valid?.should be_falsey
118
- subject.errors[:email].should == errors
123
+ expect(subject.valid?).to be_falsey
124
+ expect(subject.errors[:email]).to eq errors
119
125
  end
120
126
 
121
127
  end
@@ -123,44 +129,44 @@ describe EmailValidator do
123
129
  describe "validating email with MX and fallback to A" do
124
130
  subject { person_class_mx_with_fallback.new }
125
131
 
126
- it "should pass when email domain has MX record" do
132
+ it "passes when email domain has MX record" do
127
133
  subject.email = 'john@gmail.com'
128
- subject.valid?.should be_truthy
129
- subject.errors[:email].should be_empty
134
+ expect(subject.valid?).to be_truthy
135
+ expect(subject.errors[:email]).to be_empty
130
136
  end
131
137
 
132
- it "should pass when email domain has no MX record but has an A record" do
138
+ it "passes when email domain has no MX record but has an A record" do
133
139
  subject.email = 'john@subdomain.rubyonrails.org'
134
- subject.valid?.should be_truthy
135
- subject.errors[:email].should be_empty
140
+ expect(subject.valid?).to be_truthy
141
+ expect(subject.errors[:email]).to be_empty
136
142
  end
137
143
 
138
- it "should fail when domain does not exists" do
144
+ it "fails when domain does not exists" do
139
145
  subject.email = 'john@nonexistentdomain.abc'
140
- subject.valid?.should be_falsey
141
- subject.errors[:email].should == errors
146
+ expect(subject.valid?).to be_falsey
147
+ expect(subject.errors[:email]).to eq errors
142
148
  end
143
149
  end
144
150
 
145
151
  describe "validating email with MX" do
146
152
  subject { person_class_mx.new }
147
153
 
148
- it "should pass when email domain has MX record" do
154
+ it "passes when email domain has MX record" do
149
155
  subject.email = 'john@gmail.com'
150
- subject.valid?.should be_truthy
151
- subject.errors[:email].should be_empty
156
+ expect(subject.valid?).to be_truthy
157
+ expect(subject.errors[:email]).to be_empty
152
158
  end
153
159
 
154
- it "should fail when email domain has no MX record" do
160
+ it "fails when email domain has no MX record" do
155
161
  subject.email = 'john@subdomain.rubyonrails.org'
156
- subject.valid?.should be_falsey
157
- subject.errors[:email].should == errors
162
+ expect(subject.valid?).to be_falsey
163
+ expect(subject.errors[:email]).to eq errors
158
164
  end
159
165
 
160
- it "should fail when domain does not exists" do
166
+ it "fails when domain does not exists" do
161
167
  subject.email = 'john@nonexistentdomain.abc'
162
- subject.valid?.should be_falsey
163
- subject.errors[:email].should == errors
168
+ expect(subject.valid?).to be_falsey
169
+ expect(subject.errors[:email]).to eq errors
164
170
  end
165
171
  end
166
172
 
@@ -169,12 +175,12 @@ describe EmailValidator do
169
175
 
170
176
  context "when domain is not specified" do
171
177
  before { subject.email = 'john' }
172
- it_should_behave_like "Invalid model"
178
+ it_behaves_like "Invalid model"
173
179
  end
174
180
 
175
181
  context "when domain is not specified but @ is" do
176
182
  before { subject.email = 'john@' }
177
- it_should_behave_like "Invalid model"
183
+ it_behaves_like "Invalid model"
178
184
  end
179
185
  end
180
186
 
@@ -183,40 +189,55 @@ describe EmailValidator do
183
189
 
184
190
  context "when domain is not specified" do
185
191
  before { subject.email = 'john' }
186
- it_should_behave_like "Invalid model"
192
+ it_behaves_like "Invalid model"
187
193
  end
188
194
 
189
195
  context "when domain is not specified but @ is" do
190
196
  before { subject.email = 'john@' }
191
- it_should_behave_like "Invalid model"
197
+ it_behaves_like "Invalid model"
192
198
  end
193
199
  end
194
200
 
195
201
  describe "validating email from disposable service" do
196
202
  subject { person_class_disposable_email.new }
197
203
 
198
- it "should pass when email from trusted email services" do
204
+ it "passes when email from trusted email services" do
199
205
  subject.email = 'john@mail.ru'
200
- subject.valid?.should be_truthy
201
- subject.errors[:email].should be_empty
206
+ expect(subject.valid?).to be_truthy
207
+ expect(subject.errors[:email]).to be_empty
202
208
  end
203
209
 
204
- it "should fail when email from disposable email services" do
210
+ it "fails when email from disposable email services" do
205
211
  subject.email = 'john@grr.la'
206
- subject.valid?.should be_falsey
207
- subject.errors[:email].should == errors
212
+ expect(subject.valid?).to be_falsey
213
+ expect(subject.errors[:email]).to eq errors
208
214
  end
209
215
  end
210
216
 
217
+ describe "validating domain" do
218
+ subject { person_class_domain.new }
219
+
220
+ it "does not pass with an invalid domain" do
221
+ subject.email = "test@example.org$\'"
222
+ expect(subject.valid?).to be_falsey
223
+ expect(subject.errors[:email]).to eq errors
224
+ end
225
+
226
+ it "passes with valid domain" do
227
+ subject.email = 'john@example.org'
228
+ expect(subject.valid?).to be_truthy
229
+ expect(subject.errors[:email]).to be_empty
230
+ end
231
+ end
211
232
  end
212
233
 
213
234
  describe "Can allow nil" do
214
235
  subject { person_class_nil_allowed.new }
215
236
 
216
- it "should pass even if mail isn't set" do
237
+ it "passes even if mail isn't set" do
217
238
  subject.email = nil
218
- subject.should be_valid
219
- subject.errors[:email].should be_empty
239
+ expect(subject).to be_valid
240
+ expect(subject.errors[:email]).to be_empty
220
241
  end
221
242
 
222
243
  end
@@ -224,10 +245,10 @@ describe EmailValidator do
224
245
  describe "Can allow blank" do
225
246
  subject { person_class_blank_allowed.new }
226
247
 
227
- it "should pass even if mail is a blank string set" do
248
+ it "passes even if mail is a blank string set" do
228
249
  subject.email = ''
229
- subject.should be_valid
230
- subject.errors[:email].should be_empty
250
+ expect(subject).to be_valid
251
+ expect(subject.errors[:email]).to be_empty
231
252
  end
232
253
 
233
254
  end
@@ -235,13 +256,13 @@ describe EmailValidator do
235
256
  describe "Translating in english" do
236
257
  let!(:locale){ :en }
237
258
  let!(:errors) { [ "is invalid" ] }
238
- it_should_behave_like "Validating emails"
259
+ it_behaves_like "Validating emails"
239
260
  end
240
261
 
241
262
  describe "Translating in french" do
242
263
  let!(:locale){ :fr }
243
264
 
244
265
  let!(:errors) { [ "est invalide" ] }
245
- it_should_behave_like "Validating emails"
266
+ it_behaves_like "Validating emails"
246
267
  end
247
268
  end
@@ -3,20 +3,20 @@ require 'valid_email/all_with_extensions'
3
3
 
4
4
  describe String do
5
5
 
6
- it { "mymail@gmail".should respond_to(:email?) }
6
+ it { expect("mymail@gmail").to respond_to(:email?) }
7
7
 
8
8
  it "is a valid e-mail" do
9
- "mymail@gmail.com".email?.should be_truthy
9
+ expect("mymail@gmail.com".email?).to be_truthy
10
10
  end
11
11
 
12
12
  it "is not valid when text is not a real e-mail" do
13
- "invalidMail".email?.should be_falsey
13
+ expect("invalidMail".email?).to be_falsey
14
14
  end
15
15
 
16
16
  context "when nil" do
17
17
 
18
18
  it "is invalid e-mail" do
19
- nil.email?.should be_falsey
19
+ expect(nil.email?).to be_falsey
20
20
  end
21
21
 
22
22
  end
@@ -1,65 +1,120 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe ValidateEmail do
4
5
  describe '.valid?' do
5
- it 'should return true when passed email has valid format' do
6
- ValidateEmail.valid?('user@gmail.com').should be_truthy
7
- ValidateEmail.valid?('valid.user@gmail.com').should be_truthy
6
+ it 'returns true when passed email has valid format' do
7
+ expect(ValidateEmail.valid?('user@gmail.com')).to be_truthy
8
+ expect(ValidateEmail.valid?('valid.user@gmail.com')).to be_truthy
8
9
  end
9
10
 
10
- it 'should return false when passed email has invalid format' do
11
- ValidateEmail.valid?('user@gmail.com.').should be_falsey
12
- ValidateEmail.valid?('user.@gmail.com').should be_falsey
11
+ it 'returns false when passed email has invalid format' do
12
+ expect(ValidateEmail.valid?('user@gmail.com.')).to be_falsey
13
+ expect(ValidateEmail.valid?('user.@gmail.com')).to be_falsey
14
+ expect(ValidateEmail.valid?('Hgft@(()).com')).to be_falsey
13
15
  end
14
16
 
15
17
  context 'when mx: true option passed' do
16
- it 'should return true when mx record exist' do
17
- ValidateEmail.valid?('user@gmail.com', mx: true).should be_truthy
18
+ it 'returns true when mx record exist' do
19
+ expect(ValidateEmail.valid?('user@gmail.com', mx: true)).to be_truthy
18
20
  end
19
21
 
20
- it "should return false when mx record doesn't exist" do
21
- ValidateEmail.valid?('user@example.com', mx: true).should be_falsey
22
+ it "returns false when mx record doesn't exist" do
23
+ expect(ValidateEmail.valid?('user@example.com', mx: true)).to be_falsey
24
+ end
25
+ end
26
+
27
+ context 'when domain: true option passed' do
28
+ context 'with valid domains' do
29
+ valid_domains = [
30
+ 'example.org',
31
+ '0-mail.com',
32
+ '0815.ru',
33
+ '0clickemail.com',
34
+ 'test.co.uk',
35
+ 'fux0ringduh.com',
36
+ 'girlsundertheinfluence.com',
37
+ 'h.mintemail.com',
38
+ 'mail-temporaire.fr',
39
+ 'mt2009.com',
40
+ 'mega.zik.dj',
41
+ 'e.test.com',
42
+ 'a.aa',
43
+ 'test.xn--clchc0ea0b2g2a9gcd',
44
+ 'my-domain.com',
45
+ ]
46
+
47
+ valid_domains.each do |valid_domain|
48
+ it "returns true for #{valid_domain}" do
49
+ email = "john@#{valid_domain}"
50
+ expect(ValidateEmail.valid?(email, domain: true)).to be_truthy
51
+ end
52
+ end
53
+ end
54
+
55
+ context 'with invalid domain' do
56
+ invalid_domains = [
57
+ '-eouae.test',
58
+ 'oue-.test',
59
+ 'oeuoue.-oeuoue',
60
+ 'oueaaoeu.oeue-',
61
+ 'ouoeu.eou_ueoe',
62
+ 'тест.рф',
63
+ '.test.com',
64
+ 'test..com',
65
+ 'test@test.com',
66
+ "example.org$\'",
67
+ ]
68
+
69
+ invalid_domains.each do |invalid_domain|
70
+ it "returns false for #{invalid_domain}" do
71
+ email = "john@#{invalid_domain}"
72
+ expect(ValidateEmail.valid?(email, domain: true)).to be_falsey
73
+ end
74
+ end
22
75
  end
23
76
  end
24
77
  end
25
78
 
26
79
  describe '.valid_local?' do
27
- it 'should return false if the local segment is too long' do
28
- ValidateEmail.valid_local?(
29
- 'abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde'
30
- ).should be_falsey
80
+ it 'returns false if the local segment is too long' do
81
+ expect(
82
+ ValidateEmail.valid_local?(
83
+ 'abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde'
84
+ )
85
+ ).to be_falsey
31
86
  end
32
87
 
33
- it 'should return false if the local segment has an empty dot atom' do
34
- ValidateEmail.valid_local?('.user').should be_falsey
35
- ValidateEmail.valid_local?('.user.').should be_falsey
36
- ValidateEmail.valid_local?('user.').should be_falsey
37
- ValidateEmail.valid_local?('us..er').should be_falsey
88
+ it 'returns false if the local segment has an empty dot atom' do
89
+ expect(ValidateEmail.valid_local?('.user')).to be_falsey
90
+ expect(ValidateEmail.valid_local?('.user.')).to be_falsey
91
+ expect(ValidateEmail.valid_local?('user.')).to be_falsey
92
+ expect(ValidateEmail.valid_local?('us..er')).to be_falsey
38
93
  end
39
94
 
40
- it 'should return false if the local segment has a special character in an unquoted dot atom' do
41
- ValidateEmail.valid_local?('us@er').should be_falsey
42
- ValidateEmail.valid_local?('user.\\.name').should be_falsey
43
- ValidateEmail.valid_local?('user."name').should be_falsey
95
+ it 'returns false if the local segment has a special character in an unquoted dot atom' do
96
+ expect(ValidateEmail.valid_local?('us@er')).to be_falsey
97
+ expect(ValidateEmail.valid_local?('user.\\.name')).to be_falsey
98
+ expect(ValidateEmail.valid_local?('user."name')).to be_falsey
44
99
  end
45
100
 
46
- it 'should return false if the local segment has an unescaped special character in a quoted dot atom' do
47
- ValidateEmail.valid_local?('test." test".test').should be_falsey
48
- ValidateEmail.valid_local?('test."test\".test').should be_falsey
49
- ValidateEmail.valid_local?('test."te"st".test').should be_falsey
50
- ValidateEmail.valid_local?('test."\".test').should be_falsey
101
+ it 'returns false if the local segment has an unescaped special character in a quoted dot atom' do
102
+ expect(ValidateEmail.valid_local?('test." test".test')).to be_falsey
103
+ expect(ValidateEmail.valid_local?('test."test\".test')).to be_falsey
104
+ expect(ValidateEmail.valid_local?('test."te"st".test')).to be_falsey
105
+ expect(ValidateEmail.valid_local?('test."\".test')).to be_falsey
51
106
  end
52
107
 
53
- it 'should return true if special characters exist but are properly quoted and escaped' do
54
- ValidateEmail.valid_local?('"\ test"').should be_truthy
55
- ValidateEmail.valid_local?('"\\\\"').should be_truthy
56
- ValidateEmail.valid_local?('test."te@st".test').should be_truthy
57
- ValidateEmail.valid_local?('test."\\\\\"".test').should be_truthy
58
- ValidateEmail.valid_local?('test."blah\"\ \\\\"').should be_truthy
108
+ it 'returns true if special characters exist but are properly quoted and escaped' do
109
+ expect(ValidateEmail.valid_local?('"\ test"')).to be_truthy
110
+ expect(ValidateEmail.valid_local?('"\\\\"')).to be_truthy
111
+ expect(ValidateEmail.valid_local?('test."te@st".test')).to be_truthy
112
+ expect(ValidateEmail.valid_local?('test."\\\\\"".test')).to be_truthy
113
+ expect(ValidateEmail.valid_local?('test."blah\"\ \\\\"')).to be_truthy
59
114
  end
60
115
 
61
- it 'should return true if all characters are within the set of allowed characters' do
62
- ValidateEmail.valid_local?('!#$%&\'*+-/=?^_`{|}~."\\\\\ \"(),:;<>@[]"').should be_truthy
116
+ it 'returns true if all characters are within the set of allowed characters' do
117
+ expect(ValidateEmail.valid_local?('!#$%&\'*+-/=?^_`{|}~."\\\\\ \"(),:;<>@[]"')).to be_truthy
63
118
  end
64
119
  end
65
- end
120
+ end
data/valid_email.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://my.rails-royce.org/2010/07/21/email-validation-in-ruby-on-rails-without-regexp"
11
11
  s.summary = %q{ActiveModel Validation for email}
12
12
  s.description = %q{ActiveModel Validation for email}
13
+ s.license = 'MIT'
13
14
 
14
15
  s.rubyforge_project = "valid_email"
15
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valid_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramihajamalala Hery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -83,14 +83,18 @@ files:
83
83
  - config/locales/en.yml
84
84
  - config/locales/fi.yml
85
85
  - config/locales/fr.yml
86
+ - config/locales/hu.yml
87
+ - config/locales/ja.yml
86
88
  - config/locales/pl.yml
87
89
  - config/locales/ru.yml
88
90
  - config/locales/sv.yml
91
+ - config/locales/uk.yml
89
92
  - config/valid_email.yml
90
93
  - lib/valid_email.rb
91
94
  - lib/valid_email/all.rb
92
95
  - lib/valid_email/all_with_extensions.rb
93
96
  - lib/valid_email/ban_disposable_email_validator.rb
97
+ - lib/valid_email/domain_validator.rb
94
98
  - lib/valid_email/email_validator.rb
95
99
  - lib/valid_email/mx_validator.rb
96
100
  - lib/valid_email/mx_with_fallback_validator.rb
@@ -102,7 +106,8 @@ files:
102
106
  - spec/validate_email_spec.rb
103
107
  - valid_email.gemspec
104
108
  homepage: http://my.rails-royce.org/2010/07/21/email-validation-in-ruby-on-rails-without-regexp
105
- licenses: []
109
+ licenses:
110
+ - MIT
106
111
  metadata: {}
107
112
  post_install_message:
108
113
  rdoc_options: []
@@ -120,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
125
  version: '0'
121
126
  requirements: []
122
127
  rubyforge_project: valid_email
123
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.4.5.1
124
129
  signing_key:
125
130
  specification_version: 4
126
131
  summary: ActiveModel Validation for email
@@ -129,4 +134,3 @@ test_files:
129
134
  - spec/extensions_validator_spec.rb
130
135
  - spec/spec_helper.rb
131
136
  - spec/validate_email_spec.rb
132
- has_rdoc: