1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/library/socket/addrinfo/inspect_spec.rb
eregon b53cf149ad Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-03 16:19:40 +00:00

65 lines
1.7 KiB
Ruby

require_relative '../spec_helper'
describe 'Addrinfo#inspect' do
describe 'using an IPv4 Addrinfo' do
it 'returns a String when using a TCP Addrinfo' do
addr = Addrinfo.tcp('127.0.0.1', 80)
addr.inspect.should == '#<Addrinfo: 127.0.0.1:80 TCP>'
end
it 'returns a String when using an UDP Addrinfo' do
addr = Addrinfo.udp('127.0.0.1', 80)
addr.inspect.should == '#<Addrinfo: 127.0.0.1:80 UDP>'
end
it 'returns a String when using an Addrinfo without a port' do
addr = Addrinfo.ip('127.0.0.1')
addr.inspect.should == '#<Addrinfo: 127.0.0.1>'
end
end
describe 'using an IPv6 Addrinfo' do
it 'returns a String when using a TCP Addrinfo' do
addr = Addrinfo.tcp('::1', 80)
addr.inspect.should == '#<Addrinfo: [::1]:80 TCP>'
end
it 'returns a String when using an UDP Addrinfo' do
addr = Addrinfo.udp('::1', 80)
addr.inspect.should == '#<Addrinfo: [::1]:80 UDP>'
end
it 'returns a String when using an Addrinfo without a port' do
addr = Addrinfo.ip('::1')
addr.inspect.should == '#<Addrinfo: ::1>'
end
end
with_feature :unix_socket do
describe 'using a UNIX Addrinfo' do
it 'returns a String' do
addr = Addrinfo.unix('/foo')
addr.inspect.should == '#<Addrinfo: /foo SOCK_STREAM>'
end
it 'returns a String when using a relative UNIX path' do
addr = Addrinfo.unix('foo')
addr.inspect.should == '#<Addrinfo: UNIX foo SOCK_STREAM>'
end
it 'returns a String when using a DGRAM socket' do
addr = Addrinfo.unix('/foo', Socket::SOCK_DGRAM)
addr.inspect.should == '#<Addrinfo: /foo SOCK_DGRAM>'
end
end
end
end