2013-02-05 14:16:51 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'email'
|
|
|
|
|
|
|
|
describe Email do
|
|
|
|
|
2013-04-14 20:20:33 -04:00
|
|
|
describe "is_valid?" do
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-04-14 20:20:33 -04:00
|
|
|
it 'treats a good email as valid' do
|
2014-09-25 11:44:48 -04:00
|
|
|
Email.is_valid?('sam@sam.com').should == true
|
2013-04-14 20:20:33 -04:00
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-04-14 20:20:33 -04:00
|
|
|
it 'treats a bad email as invalid' do
|
2014-09-25 11:44:48 -04:00
|
|
|
Email.is_valid?('sam@sam').should == false
|
2013-04-14 20:20:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows museum tld' do
|
2014-09-25 11:44:48 -04:00
|
|
|
Email.is_valid?('sam@nic.museum').should == true
|
2013-04-14 20:20:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not think a word is an email' do
|
2014-09-25 11:44:48 -04:00
|
|
|
Email.is_valid?('sam').should == false
|
2013-04-14 20:20:33 -04:00
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-04-14 20:20:33 -04:00
|
|
|
describe "downcase" do
|
|
|
|
|
2014-07-14 10:16:24 -04:00
|
|
|
it 'downcases local and host part' do
|
|
|
|
Email.downcase('SAM@GMAIL.COM').should == 'sam@gmail.com'
|
|
|
|
Email.downcase('sam@GMAIL.COM').should == 'sam@gmail.com'
|
2013-04-14 20:20:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'leaves invalid emails untouched' do
|
|
|
|
Email.downcase('SAM@GMAILCOM').should == 'SAM@GMAILCOM'
|
|
|
|
Email.downcase('samGMAIL.COM').should == 'samGMAIL.COM'
|
|
|
|
Email.downcase('sam@GM@AIL.COM').should == 'sam@GM@AIL.COM'
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
2013-04-14 20:20:33 -04:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|