Sha256: 2a44227e2af07667d4a3074ec6b079565b0f971db7571a80c275e1c5687fd259

Contents?: true

Size: 1019 Bytes

Versions: 89

Compression:

Stored size: 1019 Bytes

Contents

require 'em_test_helper'
require 'socket'

class TestUnbindReason < Test::Unit::TestCase

  class StubConnection < EM::Connection
    attr_reader :error
    def unbind(reason = nil)
      @error = reason
      EM.stop
    end
  end

  def test_connect_timeout
    error = nil
    EM.run {
      conn = EM.connect 'google.com', 81, Module.new{ |m|
        m.send(:define_method, :unbind) do |reason|
          error = reason
          EM.stop
        end
      }
      conn.pending_connect_timeout = 0.1
    }
    assert_equal Errno::ETIMEDOUT, error
  end

  def test_connect_refused
    error = nil
    EM.run {
      EM.connect '127.0.0.1', 12388, Module.new{ |m|
        m.send(:define_method, :unbind) do |reason|
          error = reason
          EM.stop
        end
      }
    }
    assert_equal Errno::ECONNREFUSED, error
  end

  def test_optional_argument
    conn = nil
    EM.run {
      conn = EM.connect '127.0.0.1', 12388, StubConnection
    }
    assert_equal Errno::ECONNREFUSED, conn.error
  end
end

Version data entries

89 entries across 89 versions & 6 rubygems

Version Path
sonixlabs-eventmachine-java-1.0.0.rc.4-java tests/test_unbind_reason.rb
eventmachine-1.0.0-java tests/test_unbind_reason.rb
eventmachine-1.0.0-x86-mingw32 tests/test_unbind_reason.rb
eventmachine-1.0.0-x86-mswin32-60 tests/test_unbind_reason.rb
eventmachine-1.0.0 tests/test_unbind_reason.rb
eventmachine-le-1.1.3 tests/test_unbind_reason.rb
eventmachine-maglev--1.0.0.rc.4 tests/test_unbind_reason.rb
eventmachine-le-1.1.2 tests/test_unbind_reason.rb
eventmachine-le-1.1.1 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.4-java tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.4 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.4-x86-mswin32-60 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.4-x86-mingw32 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.3 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.3-x86-mswin32-60 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.3-x86-mingw32 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.3-java tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.2-java tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.2-x86-mswin32-60 tests/test_unbind_reason.rb
eventmachine-1.0.0.rc.2-x86-mingw32 tests/test_unbind_reason.rb