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
sensu-em-2.7.0-java tests/test_unbind_reason.rb
sensu-em-2.6.0-java tests/test_unbind_reason.rb
eventmachine-1.0.9.1 tests/test_unbind_reason.rb
eventmachine-1.0.9.1-java tests/test_unbind_reason.rb
eventmachine-1.0.9-java tests/test_unbind_reason.rb
eventmachine-1.0.9 tests/test_unbind_reason.rb
eventmachine-1.0.8 tests/test_unbind_reason.rb
eventmachine-1.0.8-java tests/test_unbind_reason.rb
sensu-em-2.5.2-java tests/test_unbind_reason.rb
sensu-em-2.5.2 tests/test_unbind_reason.rb
sensu-em-2.5.1-java tests/test_unbind_reason.rb
sensu-em-2.5.1 tests/test_unbind_reason.rb
sensu-em-2.5.0-java tests/test_unbind_reason.rb
sensu-em-2.5.0 tests/test_unbind_reason.rb
sensu-em-2.5.0.beta-java tests/test_unbind_reason.rb
sensu-em-2.5.0.beta tests/test_unbind_reason.rb
eventmachine-1.0.7 tests/test_unbind_reason.rb
eventmachine-1.0.7-java tests/test_unbind_reason.rb
sensu-em-2.4.1-java tests/test_unbind_reason.rb
sensu-em-2.4.1 tests/test_unbind_reason.rb