Sha256: cd6f7fbbce7fe9ccb8b9e9d7ad236447e5c3bff6a8fb9cff075a6acbdaf69139

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require 'em_test_helper'

class TestBasic < Test::Unit::TestCase
  def test_a
    EM.run {
      d = EM::DNS::Resolver.resolve "google.com"
      d.errback { assert false }
      d.callback { |r|
        assert r
        EM.stop
      }
    }
  end

  def test_bad_host
    EM.run {
      d = EM::DNS::Resolver.resolve "asdfasasdf"
      d.callback { assert false }
      d.errback  { assert true; EM.stop }
    }
  end

  def test_garbage
    assert_raises( ArgumentError ) {
      EM.run {
        EM::DNS::Resolver.resolve 123
      }
    }
  end

  def test_a_pair
    EM.run {
      d = EM::DNS::Resolver.resolve "google.com"
      d.errback { assert false }
      d.callback { |r|
        assert_equal(Array, r.class)
        assert r.size > 1
        EM.stop
      }
    }
  end

  def test_localhost
    EM.run {
      d = EM::DNS::Resolver.resolve "localhost"
      d.errback { assert false }
      d.callback { |r|
        assert_equal("127.0.0.1", r.first)
        assert_equal(Array, r.class)

        EM.stop
      }
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eventmachine-1.0.0.beta.3-x86-mingw32 tests/test_resolver.rb
eventmachine-1.0.0.beta.3-x86-mswin32-60 tests/test_resolver.rb
eventmachine-1.0.0.beta.3-java tests/test_resolver.rb
eventmachine-1.0.0.beta.3 tests/test_resolver.rb