2018-08-03 12:19:40 -04:00
|
|
|
require_relative '../spec_helper'
|
2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../fixtures/classes'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Socket::Option.new" do
|
|
|
|
it "should accept integers" do
|
|
|
|
so = Socket::Option.new(Socket::AF_INET, Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, [0].pack('i'))
|
|
|
|
so.family.should == Socket::AF_INET
|
|
|
|
so.level.should == Socket::SOL_SOCKET
|
|
|
|
so.optname.should == Socket::SO_KEEPALIVE
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should accept symbols" do
|
|
|
|
so = Socket::Option.new(:AF_INET, :SOL_SOCKET, :SO_KEEPALIVE, [0].pack('i'))
|
|
|
|
so.family.should == Socket::AF_INET
|
|
|
|
so.level.should == Socket::SOL_SOCKET
|
|
|
|
so.optname.should == Socket::SO_KEEPALIVE
|
|
|
|
|
|
|
|
so = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [0].pack('i'))
|
|
|
|
so.family.should == Socket::AF_INET
|
|
|
|
so.level.should == Socket::SOL_SOCKET
|
|
|
|
so.optname.should == Socket::SO_KEEPALIVE
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise error on unknown family" do
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise error on unknown level" do
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise error on unknown option name" do
|
2019-07-27 06:40:09 -04:00
|
|
|
-> { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should raise_error(SocketError)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|