diff options
Diffstat (limited to 'spec/ruby/library/socket/addrinfo/initialize_spec.rb')
| -rw-r--r-- | spec/ruby/library/socket/addrinfo/initialize_spec.rb | 140 |
1 files changed, 71 insertions, 69 deletions
diff --git a/spec/ruby/library/socket/addrinfo/initialize_spec.rb b/spec/ruby/library/socket/addrinfo/initialize_spec.rb index 8354553f61..f33255e38b 100644 --- a/spec/ruby/library/socket/addrinfo/initialize_spec.rb +++ b/spec/ruby/library/socket/addrinfo/initialize_spec.rb @@ -17,7 +17,7 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 25 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the UNSPEC pfamily" do @addrinfo.pfamily.should == Socket::PF_UNSPEC end @@ -53,11 +53,11 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 25 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET6 end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET6 end @@ -83,15 +83,15 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 25 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET6 end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET6 end - it "returns the 0 socket type" do + it "returns the specified socket type" do @addrinfo.socktype.should == Socket::SOCK_STREAM end @@ -113,11 +113,11 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 25 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET6 end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET6 end @@ -147,11 +147,11 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 46102 end - it "returns the Socket::PF_INET pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET end @@ -200,7 +200,7 @@ describe "Addrinfo#initialize" do it 'raises SocketError' do block = -> { Addrinfo.new(['AF_INET6', 80, 'hostname', '127.0.0.1']) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end @@ -217,11 +217,11 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 46102 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET end @@ -247,11 +247,11 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 46102 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET end @@ -274,15 +274,17 @@ describe "Addrinfo#initialize" do end end - with_feature :sock_packet do - [:SOCK_SEQPACKET].each do |type| - it "overwrites the socket type #{type}" do - sockaddr = ['AF_INET', 80, 'hostname', '127.0.0.1'] + platform_is_not :android do + with_feature :sock_packet do + [:SOCK_SEQPACKET].each do |type| + it "overwrites the socket type #{type}" do + sockaddr = ['AF_INET', 80, 'hostname', '127.0.0.1'] - value = Socket.const_get(type) - addr = Addrinfo.new(sockaddr, nil, value) + value = Socket.const_get(type) + addr = Addrinfo.new(sockaddr, nil, value) - addr.socktype.should == value + addr.socktype.should == value + end end end end @@ -292,7 +294,7 @@ describe "Addrinfo#initialize" do value = Socket::SOCK_RDM block = -> { Addrinfo.new(sockaddr, nil, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end @@ -309,11 +311,11 @@ describe "Addrinfo#initialize" do @addrinfo.ip_port.should == 46102 end - it "returns the Socket::UNSPEC pfamily" do + it "returns the specified pfamily" do @addrinfo.pfamily.should == Socket::PF_INET end - it "returns the INET6 afamily" do + it "returns the specified afamily" do @addrinfo.afamily.should == Socket::AF_INET end @@ -333,12 +335,12 @@ describe "Addrinfo#initialize" do @sockaddr = ['AF_INET6', 80, 'hostname', '127.0.0.1'] end - it "raises SocketError when using any Socket constant except except AF_INET(6)/PF_INET(6)" do + it "raises SocketError when using any Socket constant except AF_INET(6)/PF_INET(6)" do Socket.constants.grep(/(^AF_|^PF_)(?!INET)/).each do |constant| value = Socket.const_get(constant) -> { Addrinfo.new(@sockaddr, value) - }.should raise_error(SocketError) + }.should.raise(SocketError) end end end @@ -360,13 +362,13 @@ describe "Addrinfo#initialize" do end end - platform_is_not :windows, :aix, :solaris do + platform_is_not :windows, :aix do (Socket.constants.grep(/^IPPROTO/) - valid).each do |type| it "raises SocketError when using #{type}" do value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, nil, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -388,13 +390,13 @@ describe "Addrinfo#initialize" do end end - platform_is_not :windows, :aix, :solaris do + platform_is_not :windows, :aix do (Socket.constants.grep(/^IPPROTO/) - valid).each do |type| it "raises SocketError when using #{type}" do value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -411,7 +413,7 @@ describe "Addrinfo#initialize" do value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -442,34 +444,36 @@ describe "Addrinfo#initialize" do value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end platform_is :linux do - describe 'and the socket type is set to SOCK_SEQPACKET' do - before do - @socktype = Socket::SOCK_SEQPACKET - end + platform_is_not :android do + describe 'and the socket type is set to SOCK_SEQPACKET' do + before do + @socktype = Socket::SOCK_SEQPACKET + end - valid = [:IPPROTO_IP, :IPPROTO_HOPOPTS] + valid = [:IPPROTO_IP, :IPPROTO_HOPOPTS] - valid.each do |type| - it "overwrites the protocol when using #{type}" do - value = Socket.const_get(type) - addr = Addrinfo.new(@sockaddr, nil, @socktype, value) + valid.each do |type| + it "overwrites the protocol when using #{type}" do + value = Socket.const_get(type) + addr = Addrinfo.new(@sockaddr, nil, @socktype, value) - addr.protocol.should == value + addr.protocol.should == value + end end - end - (Socket.constants.grep(/^IPPROTO/) - valid).each do |type| - it "raises SocketError when using #{type}" do - value = Socket.const_get(type) - block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } + (Socket.constants.grep(/^IPPROTO/) - valid).each do |type| + it "raises SocketError when using #{type}" do + value = Socket.const_get(type) + block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) + end end end end @@ -491,13 +495,13 @@ describe "Addrinfo#initialize" do end end - platform_is_not :windows, :aix, :solaris do + platform_is_not :windows, :aix do (Socket.constants.grep(/^IPPROTO/) - valid).each do |type| it "raises SocketError when using #{type}" do value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -510,13 +514,13 @@ describe "Addrinfo#initialize" do @sockaddr = Socket.sockaddr_in(80, '127.0.0.1') end - it 'returns an Addrinfo with :PF_INET family' do + it 'returns an Addrinfo with the specified pfamily for :PF_INET' do addr = Addrinfo.new(@sockaddr, :PF_INET) addr.pfamily.should == Socket::PF_INET end - it 'returns an Addrinfo with :INET family' do + it 'returns an Addrinfo with the specified pfamily for :INET' do addr = Addrinfo.new(@sockaddr, :INET) addr.pfamily.should == Socket::PF_INET @@ -540,13 +544,13 @@ describe "Addrinfo#initialize" do @sockaddr = Socket.sockaddr_in(80, '127.0.0.1') end - it 'returns an Addrinfo with "PF_INET" family' do + it 'returns an Addrinfo with the specified pfamily for PF_INET' do addr = Addrinfo.new(@sockaddr, 'PF_INET') addr.pfamily.should == Socket::PF_INET end - it 'returns an Addrinfo with "INET" family' do + it 'returns an Addrinfo with the specified pfamily for INET' do addr = Addrinfo.new(@sockaddr, 'INET') addr.pfamily.should == Socket::PF_INET @@ -565,23 +569,21 @@ describe "Addrinfo#initialize" do end end - with_feature :unix_socket do - describe 'using separate arguments for a Unix socket' do - before do - @sockaddr = Socket.pack_sockaddr_un('socket') - end + describe 'using separate arguments for a Unix socket' do + before do + @sockaddr = Socket.pack_sockaddr_un('socket') + end - it 'returns an Addrinfo with the correct unix path' do - Addrinfo.new(@sockaddr).unix_path.should == 'socket' - end + it 'returns an Addrinfo with the correct unix path' do + Addrinfo.new(@sockaddr).unix_path.should == 'socket' + end - it 'returns an Addrinfo with the correct protocol family' do - Addrinfo.new(@sockaddr).pfamily.should == Socket::PF_UNSPEC - end + it 'returns an Addrinfo with the correct protocol family' do + Addrinfo.new(@sockaddr).pfamily.should == Socket::PF_UNSPEC + end - it 'returns an Addrinfo with the correct address family' do - Addrinfo.new(@sockaddr).afamily.should == Socket::AF_UNIX - end + it 'returns an Addrinfo with the correct address family' do + Addrinfo.new(@sockaddr).afamily.should == Socket::AF_UNIX end end end |
