summaryrefslogtreecommitdiff
path: root/spec/ruby/library/resolv/get_address_spec.rb
blob: eecf5e0f6fce0e0cc72cb4fa187d4b32457dc01b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require_relative '../../spec_helper'
require 'resolv'

describe "Resolv#getaddress" do
  platform_is_not :windows do
    it "resolves localhost" do
      hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
      res = Resolv.new([hosts])

      res.getaddress("localhost").should == "127.0.0.1"
      res.getaddress("localhost4").should == "127.0.0.1"
    end
  end

  it "raises ResolvError if the name can not be looked up" do
    res = Resolv.new([])
    lambda {
      res.getaddress("should.raise.error.")
    }.should raise_error(Resolv::ResolvError)
  end
end