Sha256: 60e50c9a4e3ece85ac9df4609461577e7529ff73a2119f738c32c4fdf81322b0

Contents?: true

Size: 972 Bytes

Versions: 2

Compression:

Stored size: 972 Bytes

Contents

require 'spec_helper'

describe Celluloid::IO::Reactor do
  let(:payload) { "balls" }
  let(:example_port) { assign_port }
  
  it "shouldn't crash" do
    server = ::TCPServer.new example_addr, example_port
    
    thread = Thread.new { server.accept }
    
    socket = within_io_actor { Celluloid::IO::TCPSocket.new example_addr, example_port }
    peer = thread.value
    peer_thread = Thread.new { loop { peer << payload } }
    handle = false
    
    # Main server body:
    within_io_actor do
      begin
        timeout(2) do
          loop do
            socket.readpartial(2046)
          end
        end
      # rescuing timeout, ok. rescuing terminated exception, is it ok? TODO: investigate
      rescue Celluloid::TaskTerminated, Celluloid::TaskTimeout, Timeout::Error
      ensure
        socket.readpartial(2046)
        handle = true
      end
    end
    
    expect(handle).to be_truthy
    
    server.close
    peer.close
    socket.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-io-0.17.1 spec/celluloid/io/reactor_spec.rb
celluloid-io-0.17.0 spec/celluloid/io/reactor_spec.rb