valid_email 0.0.9 → 0.0.10

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: dfc486fd0dfb112acae3207a3d736b5209daedb8
4
- data.tar.gz: c4e004a30caf02049223de8ae0f0bbf8eec8e2ac
3
+ metadata.gz: 380a2215e68ccc58972d59859e42e66ac5192e74
4
+ data.tar.gz: ca2e75012a59423ff84bc3103d6ca2f3441609f4
5
5
  SHA512:
6
- metadata.gz: 1f819b01ba5a32c6dbf8b076f3a4adc8ba7113d7ad2ebef9844ceaaa52386afa7b767894e37216771b04b16e5c6c8cc1cf1a2d8c0f3bade63f340de3bb8161b7
7
- data.tar.gz: fcb080bf8c42242267320265e878680c3dac036d3bd5364f9629cbb16b8a93ba1488c98ee2f4d3ffbd8b5593a2bf5d167fc411ac706e1e863b4e41ba685401f4
6
+ metadata.gz: 07183982261298da84f84214d363ff420c61c6bac3a8f787d449b3184e2ae4ae31b8b3fb2285ac9e5817112cc8dce7d54aadf26389062b17cbb5d30221189916
7
+ data.tar.gz: dbd5ffaf12d3fab07b3f936abc8f2e060c4046f32340781af03399580b31d0d2bedb613f6ee95f8a9a9f0020ad4402b1609a0777ca6f2648765762815de48f9d
@@ -10,11 +10,13 @@ class ValidateEmail
10
10
  # We must check that value contains a domain and that value is an email address
11
11
  r = m.domain && m.address == value
12
12
  if r
13
- # Check that domain consists of dot-atom-text elements > 1
13
+ # Check that domain consists of dot-atom-text elements > 1 and does not
14
+ # contain spaces.
15
+ #
14
16
  # In mail 2.6.1, domains are invalid per rfc2822 are parsed when they shouldn't
15
17
  # This is to make sure we cover those cases
16
18
  domain_dot_elements = m.domain.split(/\./)
17
- r &&= domain_dot_elements.none?(&:blank?) && domain_dot_elements.size > 1
19
+ r &&= m.domain.match(/^\S+$/) && domain_dot_elements.none?(&:blank?) && domain_dot_elements.size > 1
18
20
 
19
21
  # Check if domain has DNS MX record
20
22
  if r && options[:mx]
@@ -1 +1 @@
1
- ValidEmailVersion = "0.0.9"
1
+ ValidEmailVersion = "0.0.10"
@@ -66,49 +66,55 @@ describe EmailValidator do
66
66
  subject { person_class.new }
67
67
 
68
68
  it "should fail when email empty" do
69
- subject.valid?.should be_false
69
+ subject.valid?.should be_falsey
70
70
  subject.errors[:email].should == errors
71
71
  end
72
72
 
73
73
  it "should fail when email is not valid" do
74
74
  subject.email = 'joh@doe'
75
- subject.valid?.should be_false
75
+ subject.valid?.should be_falsey
76
76
  subject.errors[:email].should == errors
77
77
  end
78
78
 
79
79
  it "should fail when email domain is prefixed with dot" do
80
80
  subject.email = 'john@.doe'
81
- subject.valid?.should be_false
81
+ subject.valid?.should be_falsey
82
82
  subject.errors[:email].should == errors
83
83
  end
84
84
 
85
85
  it "should fail when email domain contains two consecutive dots" do
86
86
  subject.email = 'john@doe-two..com'
87
- subject.valid?.should be_false
87
+ subject.valid?.should be_falsey
88
88
  subject.errors[:email].should == errors
89
89
  end
90
90
 
91
91
  it "should fail when email is valid with information" do
92
92
  subject.email = '"John Doe" <john@doe.com>'
93
- subject.valid?.should be_false
93
+ subject.valid?.should be_falsey
94
94
  subject.errors[:email].should == errors
95
95
  end
96
96
 
97
97
  it "should pass when email is simple email address" do
98
98
  subject.email = 'john@doe.com'
99
- subject.valid?.should be_true
99
+ subject.valid?.should be_truthy
100
100
  subject.errors[:email].should be_empty
101
101
  end
102
102
 
103
103
  it "should fail when email is simple email address not stripped" do
104
104
  subject.email = 'john@doe.com '
105
- subject.valid?.should be_false
105
+ subject.valid?.should be_falsey
106
+ subject.errors[:email].should == errors
107
+ end
108
+
109
+ it "should fail when domain contains a space" do
110
+ subject.email = 'john@doe .com'
111
+ subject.valid?.should be_falsey
106
112
  subject.errors[:email].should == errors
107
113
  end
108
114
 
109
115
  it "should fail when passing multiple simple email addresses" do
110
116
  subject.email = 'john@doe.com, maria@doe.com'
111
- subject.valid?.should be_false
117
+ subject.valid?.should be_falsey
112
118
  subject.errors[:email].should == errors
113
119
  end
114
120
 
@@ -119,19 +125,19 @@ describe EmailValidator do
119
125
 
120
126
  it "should pass when email domain has MX record" do
121
127
  subject.email = 'john@gmail.com'
122
- subject.valid?.should be_true
128
+ subject.valid?.should be_truthy
123
129
  subject.errors[:email].should be_empty
124
130
  end
125
131
 
126
132
  it "should pass when email domain has no MX record but has an A record" do
127
133
  subject.email = 'john@subdomain.rubyonrails.org'
128
- subject.valid?.should be_true
134
+ subject.valid?.should be_truthy
129
135
  subject.errors[:email].should be_empty
130
136
  end
131
137
 
132
138
  it "should fail when domain does not exists" do
133
139
  subject.email = 'john@nonexistentdomain.abc'
134
- subject.valid?.should be_false
140
+ subject.valid?.should be_falsey
135
141
  subject.errors[:email].should == errors
136
142
  end
137
143
  end
@@ -141,19 +147,19 @@ describe EmailValidator do
141
147
 
142
148
  it "should pass when email domain has MX record" do
143
149
  subject.email = 'john@gmail.com'
144
- subject.valid?.should be_true
150
+ subject.valid?.should be_truthy
145
151
  subject.errors[:email].should be_empty
146
152
  end
147
153
 
148
154
  it "should fail when email domain has no MX record" do
149
155
  subject.email = 'john@subdomain.rubyonrails.org'
150
- subject.valid?.should be_false
156
+ subject.valid?.should be_falsey
151
157
  subject.errors[:email].should == errors
152
158
  end
153
159
 
154
160
  it "should fail when domain does not exists" do
155
161
  subject.email = 'john@nonexistentdomain.abc'
156
- subject.valid?.should be_false
162
+ subject.valid?.should be_falsey
157
163
  subject.errors[:email].should == errors
158
164
  end
159
165
  end
@@ -191,13 +197,13 @@ describe EmailValidator do
191
197
 
192
198
  it "should pass when email from trusted email services" do
193
199
  subject.email = 'john@mail.ru'
194
- subject.valid?.should be_true
200
+ subject.valid?.should be_truthy
195
201
  subject.errors[:email].should be_empty
196
202
  end
197
203
 
198
204
  it "should fail when email from disposable email services" do
199
205
  subject.email = 'john@grr.la'
200
- subject.valid?.should be_false
206
+ subject.valid?.should be_falsey
201
207
  subject.errors[:email].should == errors
202
208
  end
203
209
  end
@@ -6,19 +6,19 @@ describe String do
6
6
  it { "mymail@gmail".should respond_to(:email?) }
7
7
 
8
8
  it "is a valid e-mail" do
9
- "mymail@gmail.com".email?.should be_true
9
+ "mymail@gmail.com".email?.should 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_false
13
+ "invalidMail".email?.should 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_false
19
+ nil.email?.should be_falsey
20
20
  end
21
21
 
22
22
  end
23
23
 
24
- end
24
+ end
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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramihajamalala Hery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2014-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -74,7 +74,6 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
- - ".rvmrc"
78
77
  - ".travis.yml"
79
78
  - Gemfile
80
79
  - LICENSE
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create ruby-1.9.3@email_validator