aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/socket/addrinfo/canonname_spec.rb
blob: 15dfe86467b25be56f764a349a847640982980c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
require 'socket'

describe "Addrinfo#canonname" do

  before :each do
    @addrinfos = Addrinfo.getaddrinfo("localhost", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
  end

  it "returns the canonical name for a host" do
    canonname = @addrinfos.map { |a| a.canonname }.find { |name| name and name.include?("localhost") }
    if canonname
      canonname.should include("localhost")
    else
      canonname.should == nil
    end
  end
end