-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix domain checking logic in address.rb
- Loading branch information
1 parent
d60b89b
commit 36ab1e9
Showing
2 changed files
with
33 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,30 @@ | |
end | ||
end | ||
|
||
describe "#disposable_domain?" do | ||
let(:disposable_domain) { ValidEmail2.disposable_emails.first } | ||
|
||
it "is true if the domain is in the disposable_emails list" do | ||
address = described_class.new("foo@#{disposable_domain}") | ||
expect(address.disposable_domain?).to eq true | ||
end | ||
|
||
it "is true if the domain is a subdomain of a disposable domain" do | ||
address = described_class.new("foo@sub.#{disposable_domain}") | ||
expect(address.disposable_domain?).to eq true | ||
end | ||
|
||
it "is true if the domain is a deeply nested subdomain of a disposable domain" do | ||
address = described_class.new("[email protected].#{disposable_domain}") | ||
expect(address.disposable_domain?).to eq true | ||
end | ||
|
||
it "is false if the domain is not in the disposable_emails list" do | ||
address = described_class.new("[email protected]") | ||
expect(address.disposable_domain?).to eq false | ||
end | ||
end | ||
|
||
describe "caching" do | ||
let(:email_address) { "[email protected]" } | ||
let(:email_instance) { described_class.new(email_address) } | ||
|
@@ -181,7 +205,7 @@ | |
email_instance.valid_strict_mx? | ||
end | ||
|
||
it "calls the the MX servers lookup" do | ||
it "calls the the MX servers lookup" do | ||
email_instance.valid_strict_mx? | ||
|
||
expect(Resolv::DNS).to have_received(:open).once | ||
|
@@ -308,8 +332,8 @@ | |
stub_const("ValidEmail2::DnsRecordsCache::MAX_CACHE_SIZE", 0) | ||
end | ||
|
||
it "prunes the cache" do | ||
expect(dns_records_cache_instance).to receive(:prune_cache).once | ||
it "prunes the cache" do | ||
expect(dns_records_cache_instance).to receive(:prune_cache).once | ||
|
||
email_instance.valid_mx? | ||
end | ||
|
@@ -331,7 +355,7 @@ | |
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |