-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update domain hierarchy max depth to 3 and adjust related tests
- Loading branch information
1 parent
34dd381
commit 980e198
Showing
2 changed files
with
25 additions
and
21 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 |
---|---|---|
|
@@ -57,43 +57,47 @@ | |
end | ||
|
||
describe "#disposable_domain?" do | ||
let(:disposable_domain) { ValidEmail2.disposable_emails.first } | ||
let(:domain_hierarchy_max_depth) { 10 } | ||
|
||
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 | ||
context "when the disposable domain does not have subdomains" do | ||
let(:disposable_domain) { ValidEmail2.disposable_emails.find { |domain| domain.count(".") == 1 } } | ||
|
||
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 in the disposable_emails list" do | ||
address = described_class.new("foo@#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) | ||
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("foo@sub3.sub2.sub1.#{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}", nil, nil, domain_hierarchy_max_depth:) | ||
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 | ||
it "is true if the domain is a deeply nested subdomain of a disposable domain" do | ||
address = described_class.new("[email protected].#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) | ||
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]", nil, nil, domain_hierarchy_max_depth:) | ||
expect(address.disposable_domain?).to eq false | ||
end | ||
end | ||
|
||
context "when the disposable domain has subdomains" do | ||
let(:disposable_domain) { ValidEmail2.disposable_emails.find { |domain| domain.count(".") > 1 } } | ||
|
||
it "is true if the domain is in the disposable_emails list" do | ||
address = described_class.new("foo@#{disposable_domain}") | ||
address = described_class.new("foo@#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) | ||
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}") | ||
address = described_class.new("foo@sub.#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) | ||
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}") | ||
address = described_class.new("[email protected].#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) | ||
expect(address.disposable_domain?).to eq true | ||
end | ||
end | ||
|