mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@9be7c7e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aeeaadaad0
commit
b53cf149ad
246 changed files with 9108 additions and 548 deletions
|
@ -1,4 +1,4 @@
|
|||
require_relative '../../../spec_helper'
|
||||
require_relative '../spec_helper'
|
||||
require_relative '../fixtures/classes'
|
||||
|
||||
describe "Socket::IPSocket#addr" do
|
||||
|
@ -40,3 +40,66 @@ describe "Socket::IPSocket#addr" do
|
|||
addrinfo[3].should == "127.0.0.1"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Socket::IPSocket#addr' do
|
||||
SocketSpecs.each_ip_protocol do |family, ip_address, family_name|
|
||||
before do
|
||||
@server = TCPServer.new(ip_address, 0)
|
||||
@port = @server.connect_address.ip_port
|
||||
end
|
||||
|
||||
after do
|
||||
@server.close
|
||||
end
|
||||
|
||||
describe 'without reverse lookups' do
|
||||
before do
|
||||
@hostname = Socket.getaddrinfo(ip_address, nil)[0][2]
|
||||
end
|
||||
|
||||
it 'returns an Array containing address information' do
|
||||
@server.addr.should == [family_name, @port, @hostname, ip_address]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with reverse lookups' do
|
||||
before do
|
||||
@hostname = Socket.getaddrinfo(ip_address, nil, nil, 0, 0, 0, true)[0][2]
|
||||
end
|
||||
|
||||
describe 'using true as the argument' do
|
||||
it 'returns an Array containing address information' do
|
||||
@server.addr(true).should == [family_name, @port, @hostname, ip_address]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'using :hostname as the argument' do
|
||||
it 'returns an Array containing address information' do
|
||||
@server.addr(:hostname).should == [family_name, @port, @hostname, ip_address]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'using :cats as the argument' do
|
||||
it 'raises ArgumentError' do
|
||||
lambda { @server.addr(:cats) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with do_not_reverse_lookup disabled on socket level' do
|
||||
before do
|
||||
@server.do_not_reverse_lookup = false
|
||||
|
||||
@hostname = Socket.getaddrinfo(ip_address, nil, nil, 0, 0, 0, true)[0][2]
|
||||
end
|
||||
|
||||
after do
|
||||
@server.do_not_reverse_lookup = true
|
||||
end
|
||||
|
||||
it 'returns an Array containing address information' do
|
||||
@server.addr.should == [family_name, @port, @hostname, ip_address]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue