Sha256: 159f0e98ee523dfab1c0fdb2ddeb24e9f396193d4529f7da75c4d9e77c6f4f29

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

require File.expand_path('../../fixtures/classes', __FILE__)

ruby_version_is "1.9.2" do
  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
      lambda { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
    end
    it "should raise error on unknown level" do
      lambda { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
    end
    it "should raise error on unknown option name" do
      lambda { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should raise_error(SocketError)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysl-socket-1.0.1 spec/option/new_spec.rb
rubysl-socket-2.0.1 spec/option/new_spec.rb
rubysl-socket-1.0.0 spec/option/new_spec.rb
rubysl-socket-2.0.0 spec/option/new_spec.rb