ruby-changes:62754
From: Benoit <ko1@a...>
Date: Sat, 29 Aug 2020 19:31:00 +0900 (JST)
Subject: [ruby-changes:62754] 1199f1a4aa (master): Fix warnings related to new Socket.gethostby* deprecations
https://git.ruby-lang.org/ruby.git/commit/?id=1199f1a4aa From 1199f1a4aac3946cb427f2bed73948b02ee14a74 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sat, 29 Aug 2020 11:58:05 +0200 Subject: Fix warnings related to new Socket.gethostby* deprecations diff --git a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb index 8bebeb0..a4c8355 100644 --- a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb +++ b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb @@ -10,12 +10,12 @@ describe 'Socket.gethostbyaddr' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb#L10 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb#L49 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb#L70 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb#L106 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 diff --git a/spec/ruby/library/socket/socket/gethostbyname_spec.rb b/spec/ruby/library/socket/socket/gethostbyname_spec.rb index 2696f44..0858e25 100644 --- a/spec/ruby/library/socket/socket/gethostbyname_spec.rb +++ b/spec/ruby/library/socket/socket/gethostbyname_spec.rb @@ -4,24 +4,24 @@ require_relative '../fixtures/classes' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyname_spec.rb#L4 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyname_spec.rb#L54 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyname_spec.rb#L74 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyname_spec.rb#L94 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/gethostbyname_spec.rb#L115 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/