Sha256: 1996ddacbfa0c7ab3936d61253d021c0ed838b9051badff6eff6d8ca38558919

Contents?: true

Size: 817 Bytes

Versions: 4

Compression:

Stored size: 817 Bytes

Contents

require File.expand_path('../spec_helper', __FILE__)

VALID_DOMAIN = "google.com"
INVALID_DOMAIN = "gibidigibigididibitidibigitibidigitidididi.com"

class ItWorked < StandardError; end
class WontResolve < StandardError; end

class ConnectorThingy < Cool.io::TCPSocket
  def on_connect
    raise ItWorked
  end

  def on_resolve_failed
    raise WontResolve
  end
end

describe "DNS" do
  before :each do
    @loop = Cool.io::Loop.new
  end
  
  it "connects to valid domains" do
    ConnectorThingy.connect(VALID_DOMAIN, 80).attach(@loop)
    
    proc do
      @loop.run
    end.should raise_error(ItWorked)
  end
  
  it "fires on_resolve_failed for invalid domains" do
    ConnectorThingy.connect(INVALID_DOMAIN, 80).attach(@loop)
    
    proc do
      @loop.run
    end.should raise_error(WontResolve)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cool.io-1.3.0 spec/dns_spec.rb
cool.io-1.2.4 spec/dns_spec.rb
cool.io-1.2.3-x86-mingw32 spec/dns_spec.rb
cool.io-1.2.3 spec/dns_spec.rb