|
105 | 105 | end |
106 | 106 | end |
107 | 107 |
|
| 108 | + describe "#disposable_domain?" do |
| 109 | + let(:domain_hierarchy_max_depth) { 10 } |
| 110 | + |
| 111 | + context "when the disposable domain does not have subdomains" do |
| 112 | + let(:disposable_domain) { ValidEmail2.disposable_emails.find { |domain| domain.count(".") == 1 } } |
| 113 | + |
| 114 | + it "is true if the domain is in the disposable_emails list" do |
| 115 | + address = described_class.new("foo@#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) |
| 116 | + expect(address.disposable_domain?).to eq true |
| 117 | + end |
| 118 | + |
| 119 | + it "is true if the domain is a subdomain of a disposable domain" do |
| 120 | + address = described_class.new("foo@sub.#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) |
| 121 | + expect(address.disposable_domain?).to eq true |
| 122 | + end |
| 123 | + |
| 124 | + it "is true if the domain is a deeply nested subdomain of a disposable domain" do |
| 125 | + address = described_class.new("foo@sub3.sub2.sub1.#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) |
| 126 | + expect(address.disposable_domain?).to eq true |
| 127 | + end |
| 128 | + |
| 129 | + it "is false if the domain is not in the disposable_emails list" do |
| 130 | + address = described_class.new("foo@example.com", nil, nil, domain_hierarchy_max_depth:) |
| 131 | + expect(address.disposable_domain?).to eq false |
| 132 | + end |
| 133 | + end |
| 134 | + |
| 135 | + context "when the disposable domain has subdomains" do |
| 136 | + let(:disposable_domain) { ValidEmail2.disposable_emails.find { |domain| domain.count(".") > 1 } } |
| 137 | + |
| 138 | + it "is true if the domain is in the disposable_emails list" do |
| 139 | + address = described_class.new("foo@#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) |
| 140 | + expect(address.disposable_domain?).to eq true |
| 141 | + end |
| 142 | + |
| 143 | + it "is true if the domain is a subdomain of a disposable domain" do |
| 144 | + address = described_class.new("foo@sub.#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) |
| 145 | + expect(address.disposable_domain?).to eq true |
| 146 | + end |
| 147 | + |
| 148 | + it "is true if the domain is a deeply nested subdomain of a disposable domain" do |
| 149 | + address = described_class.new("foo@sub3.sub2.sub1.#{disposable_domain}", nil, nil, domain_hierarchy_max_depth:) |
| 150 | + expect(address.disposable_domain?).to eq true |
| 151 | + end |
| 152 | + end |
| 153 | + end |
| 154 | + |
108 | 155 | describe "caching" do |
109 | 156 | let(:email_address) { "example@ymail.com" } |
110 | 157 | let(:dns_instance) { ValidEmail2::Dns.new } |
|
0 commit comments