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

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

      res.getname("127.0.0.1").should == "localhost"
    end
  end

  it "raises ResolvError when there is no result" do
    res = Resolv.new([])
    lambda {
      res.getname("should.raise.error")
    }.should raise_error(Resolv::ResolvError)
  end
end