spotify/rspec-dns — pull request #14 by otahi (2014-10-11 23:34:00+00:00)
Title: [WIP] Dispense with reverse IP addresses

For PTR records, we need to reverse IP addresses. I want to dispense with reversed IP addresses.

I want to pass both examples.
```
$ bundle exec rspec

74.125.28.27
should have the correct dns entries with {:type=>"PTR", :domainname=>"pc-in-f27.1e100.net", :with=>"exceptions"}

27.28.125.74.in-addr.arpa.
should have the correct dns entries with {:type=>"PTR", :domainname=>"pc-in-f27.1e100.net"}
```

I will do the followings.
- [ ] Add an example to README.md
- [ ] Add spec for not reversed IP address case
- [ ] Add implementation

------
## Investigation
For example, `gmail-smtp-in.l.google.com` is `74.125.28.27`, `74.125.28.27` can provide `pc-in-f27.1e100.net` domainname in PTR record.

### dig
Dig can resolve without reversed IP address.
```
$ dig -x 74.125.28.27 +short
pc-in-f27.1e100.net.
$
```

### dnsruby
Dnsruby can resolve without reversed IP address when type is PTR.
```
require 'dnsruby'
resolver = Dnsruby::Resolver.new
begin
resolver.query('74.125.28.27', Dnsruby::Types.ANY)
rescue => e
e
end
=> #

resolver.query('27.28.125.74.in-addr.arpa.', Dnsruby::Types.ANY).answer[0].instance_variable_get('@domainname')
=> #

resolver.query('74.125.28.27', Dnsruby::Types.PTR).answer[0].instance_variable_get('@domainname')
=> #
```

### rspec-dns
Rspec-dns can resolve only with fully reversed IP address.
```
rspec-dns
require 'rspec'
require 'rspec-dns'
describe '74.125.28.27' do
it { is_expected.to have_dns.with_type('PTR').and_domainname('pc-in-f27.1e100.net') }
end

describe '27.28.125.74.in-addr.arpa.' do
it { is_expected.to have_dns.with_type('PTR').and_domainname('pc-in-f27.1e100.net') }
end
```

```
$ bundle exec rspec

74.125.28.27
should have the correct dns entries with {:type=>"PTR", :domainname=>"pc-in-f27.1e100.net", :with=>"exceptions"} (FAILED - 1)

27.28.125.74.in-addr.arpa.
should have the correct dns entries with {:type=>"PTR", :domainname=>"pc-in-f27.1e100.net"}
```