Class: MailResolver::Testing::FakeResolver
- Inherits:
-
Object
- Object
- MailResolver::Testing::FakeResolver
- Defined in:
- lib/mailresolver/testing.rb
Overview
A zone in a hash: missing names raise NoSuchName, missing types raise NotFound, and :timeout/:servfail/:nxdomain stand in for misbehavior. PTR is keyed by address.
FakeResolver.new("example.com" => { txt: [ "v=spf1 -all" ], mx: :servfail })
Instance Attribute Summary collapse
-
#queries ⇒ Object
readonly
Returns the value of attribute queries.
Instance Method Summary collapse
- #a(name) ⇒ Object
- #aaaa(name) ⇒ Object
-
#addresses(name) ⇒ Object
A missing family contributes nothing; NXDOMAIN or nameserver failure still raises.
- #cname(name) ⇒ Object
-
#initialize(zone = {}) ⇒ FakeResolver
constructor
A new instance of FakeResolver.
- #mx(name) ⇒ Object
- #ptr(address) ⇒ Object
- #txt(name) ⇒ Object
Constructor Details
#initialize(zone = {}) ⇒ FakeResolver
Returns a new instance of FakeResolver.
16 17 18 19 |
# File 'lib/mailresolver/testing.rb', line 16 def initialize(zone = {}) @zone = zone.transform_keys { |name| normalized(name) } @queries = [] end |
Instance Attribute Details
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
14 15 16 |
# File 'lib/mailresolver/testing.rb', line 14 def queries @queries end |
Instance Method Details
#a(name) ⇒ Object
25 26 27 |
# File 'lib/mailresolver/testing.rb', line 25 def a(name) lookup(name, :a) end |
#aaaa(name) ⇒ Object
29 30 31 |
# File 'lib/mailresolver/testing.rb', line 29 def aaaa(name) lookup(name, :aaaa) end |
#addresses(name) ⇒ Object
A missing family contributes nothing; NXDOMAIN or nameserver failure still raises.
34 35 36 |
# File 'lib/mailresolver/testing.rb', line 34 def addresses(name) %i[ a aaaa ].flat_map { |type| family(type, name) } end |
#cname(name) ⇒ Object
46 47 48 |
# File 'lib/mailresolver/testing.rb', line 46 def cname(name) lookup(name, :cname) end |
#mx(name) ⇒ Object
38 39 40 |
# File 'lib/mailresolver/testing.rb', line 38 def mx(name) lookup(name, :mx) end |
#ptr(address) ⇒ Object
42 43 44 |
# File 'lib/mailresolver/testing.rb', line 42 def ptr(address) lookup(address, :ptr) end |
#txt(name) ⇒ Object
21 22 23 |
# File 'lib/mailresolver/testing.rb', line 21 def txt(name) lookup(name, :txt) end |