2018-03-04 15:09:32 +00:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 12:04:49 +00:00
|
|
|
require 'resolv'
|
|
|
|
|
|
|
|
describe "Resolv#getaddress" do
|
2019-06-10 12:47:08 +02:00
|
|
|
it "resolves localhost" do
|
|
|
|
hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
|
|
|
|
res = Resolv.new([hosts])
|
2017-05-07 12:04:49 +00:00
|
|
|
|
2019-06-10 12:47:08 +02:00
|
|
|
res.getaddress("localhost").should == "127.0.0.1"
|
|
|
|
res.getaddress("localhost4").should == "127.0.0.1"
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises ResolvError if the name can not be looked up" do
|
|
|
|
res = Resolv.new([])
|
2019-07-27 12:40:09 +02:00
|
|
|
-> {
|
2017-05-07 12:04:49 +00:00
|
|
|
res.getaddress("should.raise.error.")
|
|
|
|
}.should raise_error(Resolv::ResolvError)
|
|
|
|
end
|
|
|
|
end
|