|
55 | 55 |
|
56 | 56 | it "is valid if it contains special scandinavian characters" do |
57 | 57 | address = described_class.new("jørgen@email.dk") |
58 | | - expect(address.valid?).to eq true |
| 58 | + expect(address.valid?).to be_truthy |
| 59 | + end |
| 60 | + end |
| 61 | + end |
| 62 | + |
| 63 | + describe "#disposable_domain?" do |
| 64 | + context "when the disposable domain does not have subdomains" do |
| 65 | + let(:disposable_domain) { ValidEmail2.disposable_emails.select { |domain| domain.count(".") == 1 }.sample } |
| 66 | + |
| 67 | + it "is true if the domain is in the disposable_emails list" do |
| 68 | + address = described_class.new("foo@#{disposable_domain}") |
| 69 | + expect(address.disposable_domain?).to be_truthy |
| 70 | + end |
| 71 | + |
| 72 | + it "is true if the domain is a subdomain of a disposable domain" do |
| 73 | + address = described_class.new("foo@sub.#{disposable_domain}") |
| 74 | + expect(address.disposable_domain?).to be_truthy |
| 75 | + end |
| 76 | + |
| 77 | + it "is true if the domain is a deeply nested subdomain of a disposable domain" do |
| 78 | + address = described_class.new("foo@sub3.sub2.sub1.#{disposable_domain}") |
| 79 | + expect(address.disposable_domain?).to be_truthy |
| 80 | + end |
| 81 | + |
| 82 | + it "is false if the domain is not in the disposable_emails list" do |
| 83 | + address = described_class.new("foo@example.com") |
| 84 | + expect(address.disposable_domain?).to eq false |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + context "when the disposable domain has subdomains" do |
| 89 | + let(:disposable_domain) { ValidEmail2.disposable_emails.select { |domain| domain.count(".") > 1 }.sample } |
| 90 | + |
| 91 | + it "is true if the domain is in the disposable_emails list" do |
| 92 | + address = described_class.new("foo@#{disposable_domain}") |
| 93 | + expect(address.disposable_domain?).to be_truthy |
| 94 | + end |
| 95 | + |
| 96 | + it "is true if the domain is a subdomain of a disposable domain" do |
| 97 | + address = described_class.new("foo@sub.#{disposable_domain}") |
| 98 | + expect(address.disposable_domain?).to be_truthy |
| 99 | + end |
| 100 | + |
| 101 | + it "is true if the domain is a deeply nested subdomain of a disposable domain" do |
| 102 | + address = described_class.new("foo@sub3.sub2.sub1.#{disposable_domain}") |
| 103 | + expect(address.disposable_domain?).to be_truthy |
59 | 104 | end |
60 | 105 | end |
61 | 106 | end |
|
0 commit comments