spec/celluloid/io/dns_resolver_spec.rb in celluloid-io-0.16.0 vs spec/celluloid/io/dns_resolver_spec.rb in celluloid-io-0.16.1
- old
+ new
@@ -1,16 +1,26 @@
require 'spec_helper'
describe Celluloid::IO::DNSResolver do
describe '#resolve' do
+ it 'resolves hostnames statically from hosts file without nameservers' do
+ # /etc/resolv.conf doesn't exist on Mac OSX when no networking is
+ # disabled, thus .nameservers would return nil
+ Celluloid::IO::DNSResolver.should_receive(:nameservers).at_most(:once) { nil }
+ resolver = Celluloid::IO::DNSResolver.new
+ resolver.resolve('localhost').should eq Resolv::IPv4.create("127.0.0.1")
+ end
+
it 'resolves hostnames' do
resolver = Celluloid::IO::DNSResolver.new
resolver.resolve('localhost').should eq Resolv::IPv4.create("127.0.0.1")
end
it "resolves domain names" do
- resolver = Celluloid::IO::DNSResolver.new
- resolver.resolve("celluloid.io").should == Resolv::IPv4.create("207.97.227.245")
+ resolver = Celluloid::IO::DNSResolver.new
+ nameservers = resolver.resolve("celluloid.io")
+ expect(nameservers).to include Resolv::IPv4.create("104.28.21.100")
+ expect(nameservers).to include Resolv::IPv4.create("104.28.20.100")
end
it "resolves CNAME responses" do
resolver = Celluloid::IO::DNSResolver.new
results = resolver.resolve("www.google.com")