-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: Bump version to `2.2.1` Add `rubocop-rake` to dev dependencies Enforce domain character limit Allow mailbox-only addresses in `:rfc` mode Fix regexp for numeric subdomains (fixes #68) [specs] Add tests for numeric subdomains
- Loading branch information
Showing
6 changed files
with
203 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,13 @@ class DefaultUserWithMessage < TestModel | |
'[email protected]', | ||
'mixed-1234-in-{+^}[email protected]', | ||
'partially."quoted"@sld.com', | ||
'areallylongnameaasdfasdfasdfasdf@asdfasdfasdfasdfasdf.ab.cd.ef.gh.co.ca' | ||
'areallylongnameaasdfasdfasdfasdf@asdfasdfasdfasdfasdf.ab.cd.ef.gh.co.ca', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]' | ||
]).flatten.each do |email| | ||
context 'when using defaults' do | ||
it "'#{email}' should be valid" do | ||
|
@@ -260,6 +266,132 @@ class DefaultUserWithMessage < TestModel | |
end | ||
end | ||
|
||
context 'when given the numeric domain' do | ||
[ | ||
'[email protected]' | ||
].each do |email| | ||
context 'when using defaults' do | ||
it "'#{email}' should be valid" do | ||
expect(DefaultUser.new(:email => email)).to be_valid | ||
end | ||
|
||
it "'#{email}' should be valid using EmailValidator.valid?" do | ||
expect(described_class).to be_valid(email) | ||
end | ||
|
||
it "'#{email}' should not be invalid using EmailValidator.invalid?" do | ||
expect(described_class).not_to be_invalid(email) | ||
end | ||
|
||
it "'#{email}' should match the regexp" do | ||
expect(!!(email.strip =~ described_class.regexp)).to be(true) | ||
end | ||
end | ||
|
||
context 'when in `:strict` mode' do | ||
it "'#{email}' should not be valid" do | ||
expect(StrictUser.new(:email => email)).not_to be_valid | ||
end | ||
|
||
it "'#{email}' should not be valid using EmailValidator.valid?" do | ||
expect(described_class).not_to be_valid(email, :mode => :strict) | ||
end | ||
|
||
it "'#{email}' should be invalid using EmailValidator.invalid?" do | ||
expect(described_class).to be_invalid(email, :mode => :strict) | ||
end | ||
|
||
it "'#{email}' should not match the regexp" do | ||
expect(!!(email.strip =~ described_class.regexp(:mode => :strict))).to be(false) | ||
end | ||
end | ||
|
||
context 'when in `:rfc` mode' do | ||
it "'#{email}' should be valid" do | ||
expect(RfcUser.new(:email => email)).to be_valid | ||
end | ||
|
||
it "'#{email}' should be valid using EmailValidator.valid?" do | ||
expect(described_class).to be_valid(email, :mode => :rfc) | ||
end | ||
|
||
it "'#{email}' should not be invalid using EmailValidator.invalid?" do | ||
expect(described_class).not_to be_invalid(email, :mode => :rfc) | ||
end | ||
|
||
it "'#{email}' should match the regexp" do | ||
expect(!!(email.strip =~ described_class.regexp(:mode => :rfc))).to be(true) | ||
end | ||
end | ||
end | ||
end | ||
|
||
context 'when given the valid mailbox-only email' do | ||
valid_includable.map { |k, v| [ | ||
"user-#{v}-#{k}-name" | ||
]}.concat(valid_beginable.map { |k, v| [ | ||
"#{v}-start-with-#{k}-user" | ||
]}).concat(valid_endable.map { |k, v| [ | ||
"end-with-#{k}-#{v}" | ||
]}).concat([ | ||
'user' | ||
]).flatten.each do |email| | ||
context 'when using defaults' do | ||
it "'#{email}' should not be valid" do | ||
expect(DefaultUser.new(:email => email)).not_to be_valid | ||
end | ||
|
||
it "'#{email}' should not be valid using EmailValidator.valid?" do | ||
expect(described_class).not_to be_valid(email) | ||
end | ||
|
||
it "'#{email}' should be invalid using EmailValidator.invalid?" do | ||
expect(described_class).to be_invalid(email) | ||
end | ||
|
||
it "'#{email}' should not match the regexp" do | ||
expect(!!(email.strip =~ described_class.regexp)).to be(false) | ||
end | ||
end | ||
|
||
context 'when in `:strict` mode' do | ||
it "'#{email}' should not be valid" do | ||
expect(StrictUser.new(:email => email)).not_to be_valid | ||
end | ||
|
||
it "'#{email}' should not be valid using EmailValidator.valid?" do | ||
expect(described_class).not_to be_valid(email, :mode => :strict) | ||
end | ||
|
||
it "'#{email}' should be invalid using EmailValidator.invalid?" do | ||
expect(described_class).to be_invalid(email, :mode => :strict) | ||
end | ||
|
||
it "'#{email}' should not match the regexp" do | ||
expect(!!(email.strip =~ described_class.regexp(:mode => :strict))).to be(false) | ||
end | ||
end | ||
|
||
context 'when in `:rfc` mode' do | ||
it "'#{email}' should be valid" do | ||
expect(RfcUser.new(:email => email)).to be_valid | ||
end | ||
|
||
it "'#{email}' should be valid using EmailValidator.valid?" do | ||
expect(described_class).to be_valid(email, :mode => :rfc) | ||
end | ||
|
||
it "'#{email}' should not be invalid using EmailValidator.invalid?" do | ||
expect(described_class).not_to be_invalid(email, :mode => :rfc) | ||
end | ||
|
||
it "'#{email}' should match the regexp" do | ||
expect(!!(email.strip =~ described_class.regexp(:mode => :rfc))).to be(true) | ||
end | ||
end | ||
end | ||
end | ||
|
||
context 'when given the valid IP address email' do | ||
[ | ||
'bracketed-IP@[127.0.0.1]', | ||
|
@@ -334,8 +466,6 @@ class DefaultUserWithMessage < TestModel | |
'[email protected]@example.com', | ||
'[email protected]', | ||
'missing-tld@sld.', | ||
'[email protected]', | ||
'[email protected]', | ||
'unbracketed-IPv6@abcd:ef01:1234:5678:9abc:def0:1234:5678', | ||
'unbracketed-and-labled-IPv6@IPv6:abcd:ef01:1234:5678:9abc:def0:1234:5678', | ||
'bracketed-and-unlabeled-IPv6@[abcd:ef01:1234:5678:9abc:def0:1234:5678]', | ||
|
@@ -347,6 +477,7 @@ class DefaultUserWithMessage < TestModel | |
'[email protected]', | ||
'[email protected]', | ||
'the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.dev', | ||
"domain-too-long@t#{".#{'o' * 63}" * 5}.long", | ||
"[email protected]<script>alert('hello')</script>" | ||
]).flatten.each do |email| | ||
context 'when using defaults' do | ||
|
@@ -504,8 +635,7 @@ class DefaultUserWithMessage < TestModel | |
'@bar.com', | ||
'test@', | ||
'@missing-local.dev', | ||
' ', | ||
'missing-at-sign.dev' | ||
' ' | ||
].each do |email| | ||
context 'when using defaults' do | ||
it "'#{email}' should not be valid" do | ||
|