Sha256: 06d462c2393ef36b91f54d241c18c2d74ccff191261444d097b0644e3b11ea14

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

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

ruby_version_is "1.9.2" do
  describe "Socket::Option.int" do
    it "creates a new Socket::Option for SO_LINGER" do
      so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 5)
      so.family.should == Socket::Constants::AF_INET
      so.level.should == Socket::Constants::SOL_SOCKET
      so.optname.should == Socket::Constants::SO_KEEPALIVE
      so.data.should == [5].pack('i')
    end
  end

  describe "Socket::Option#int" do
    it "returns int option" do
      so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 17)
      so.int.should == 17

      so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 32765)
      so.int.should == 32765
    end
    it "raises TypeError if option has not good size" do
      so = Socket::Option.new(:UNSPEC, :SOCKET, :KEEPALIVE, [0, 0].pack('i*'))
      lambda { so.int }.should raise_error(TypeError)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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