Sha256: 3d17c6a711e10930ebceb842a9159b103c574d2caf7e63b7c4f2fe1b871d95f9

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

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

describe "Socket::BasicSocket#close_read" do
  before :each do
    @server = TCPServer.new(SocketSpecs.port)
  end

  after :each do
    @server.close unless @server.closed?
  end

  it "closes the reading end of the socket" do
    @server.close_read
    lambda { @server.read }.should raise_error(IOError)
  end

  it "it works on sockets with closed ends" do
    @server.close_read
    lambda { @server.close_read }.should_not raise_error(Exception)
    lambda { @server.read }.should raise_error(IOError)
  end

  it "does not close the socket" do
    @server.close_read
    @server.closed?.should be_false
  end

  it "fully closes the socket if it was already closed for writing" do
    @server.close_write
    @server.close_read
    @server.closed?.should be_true
  end

  it "raises IOError on closed socket" do
    @server.close
    lambda { @server.close_read }.should raise_error(IOError)
  end

  it "returns nil" do
    @server.close_read.should be_nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysl-socket-1.0.1 spec/basicsocket/close_read_spec.rb
rubysl-socket-2.0.1 spec/basicsocket/close_read_spec.rb
rubysl-socket-1.0.0 spec/basicsocket/close_read_spec.rb
rubysl-socket-2.0.0 spec/basicsocket/close_read_spec.rb