1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix warnings related to new Socket.gethostby* deprecations

This commit is contained in:
Benoit Daloze 2020-08-29 11:58:05 +02:00
parent 232d6c4077
commit 1199f1a4aa
2 changed files with 18 additions and 18 deletions

View file

@ -10,12 +10,12 @@ describe 'Socket.gethostbyaddr' do
describe 'without an explicit address family' do
it 'returns an Array' do
Socket.gethostbyaddr(@addr).should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyaddr(@addr) }.should be_an_instance_of(Array)
end
describe 'the returned Array' do
before do
@array = Socket.gethostbyaddr(@addr)
@array = suppress_warning { Socket.gethostbyaddr(@addr) }
end
# RubyCI Solaris 11x defines 127.0.0.1 as unstable11x
@ -49,15 +49,15 @@ describe 'Socket.gethostbyaddr' do
describe 'with an explicit address family' do
it 'returns an Array when using an Integer as the address family' do
Socket.gethostbyaddr(@addr, Socket::AF_INET).should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyaddr(@addr, Socket::AF_INET) }.should be_an_instance_of(Array)
end
it 'returns an Array when using a Symbol as the address family' do
Socket.gethostbyaddr(@addr, :INET).should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyaddr(@addr, :INET) }.should be_an_instance_of(Array)
end
it 'raises SocketError when the address is not supported by the family' do
-> { Socket.gethostbyaddr(@addr, :INET6) }.should raise_error(SocketError)
-> { suppress_warning { Socket.gethostbyaddr(@addr, :INET6) } }.should raise_error(SocketError)
end
end
end
@ -70,12 +70,12 @@ describe 'Socket.gethostbyaddr' do
describe 'without an explicit address family' do
it 'returns an Array' do
Socket.gethostbyaddr(@addr).should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyaddr(@addr) }.should be_an_instance_of(Array)
end
describe 'the returned Array' do
before do
@array = Socket.gethostbyaddr(@addr)
@array = suppress_warning { Socket.gethostbyaddr(@addr) }
end
it 'includes the hostname as the first value' do
@ -106,16 +106,16 @@ describe 'Socket.gethostbyaddr' do
describe 'with an explicit address family' do
it 'returns an Array when using an Integer as the address family' do
Socket.gethostbyaddr(@addr, Socket::AF_INET6).should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyaddr(@addr, Socket::AF_INET6) }.should be_an_instance_of(Array)
end
it 'returns an Array when using a Symbol as the address family' do
Socket.gethostbyaddr(@addr, :INET6).should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyaddr(@addr, :INET6) }.should be_an_instance_of(Array)
end
platform_is_not :windows, :wsl do
it 'raises SocketError when the address is not supported by the family' do
-> { Socket.gethostbyaddr(@addr, :INET) }.should raise_error(SocketError)
-> { suppress_warning { Socket.gethostbyaddr(@addr, :INET) } }.should raise_error(SocketError)
end
end
end

View file

@ -4,24 +4,24 @@ require_relative '../fixtures/classes'
describe "Socket.gethostbyname" do
it "returns broadcast address info for '<broadcast>'" do
addr = Socket.gethostbyname('<broadcast>');
addr = suppress_warning { Socket.gethostbyname('<broadcast>') }
addr.should == ["255.255.255.255", [], 2, "\xFF\xFF\xFF\xFF"]
end
it "returns broadcast address info for '<any>'" do
addr = Socket.gethostbyname('<any>');
addr = suppress_warning { Socket.gethostbyname('<any>') }
addr.should == ["0.0.0.0", [], 2, "\x00\x00\x00\x00"]
end
end
describe 'Socket.gethostbyname' do
it 'returns an Array' do
Socket.gethostbyname('127.0.0.1').should be_an_instance_of(Array)
suppress_warning { Socket.gethostbyname('127.0.0.1') }.should be_an_instance_of(Array)
end
describe 'the returned Array' do
before do
@array = Socket.gethostbyname('127.0.0.1')
@array = suppress_warning { Socket.gethostbyname('127.0.0.1') }
end
it 'includes the hostname as the first value' do
@ -54,7 +54,7 @@ describe 'Socket.gethostbyname' do
describe 'using <broadcast> as the input address' do
describe 'the returned Array' do
before do
@addr = Socket.gethostbyname('<broadcast>')
@addr = suppress_warning { Socket.gethostbyname('<broadcast>') }
end
it 'includes the broadcast address as the first value' do
@ -74,7 +74,7 @@ describe 'Socket.gethostbyname' do
describe 'using <any> as the input address' do
describe 'the returned Array' do
before do
@addr = Socket.gethostbyname('<any>')
@addr = suppress_warning { Socket.gethostbyname('<any>') }
end
it 'includes the wildcard address as the first value' do
@ -94,7 +94,7 @@ describe 'Socket.gethostbyname' do
describe 'using an IPv4 address' do
describe 'the returned Array' do
before do
@addr = Socket.gethostbyname('127.0.0.1')
@addr = suppress_warning { Socket.gethostbyname('127.0.0.1') }
end
it 'includes the IP address as the first value' do
@ -115,7 +115,7 @@ describe 'Socket.gethostbyname' do
describe 'using an IPv6 address' do
describe 'the returned Array' do
before do
@addr = Socket.gethostbyname('::1')
@addr = suppress_warning { Socket.gethostbyname('::1') }
end
it 'includes the IP address as the first value' do