Sha256: 7220ec6abc50f55d897c1e2031b095f209d53785fbc593a4ca4cb3c1b2fb6798

Contents?: true

Size: 816 Bytes

Versions: 8

Compression:

Stored size: 816 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

8 entries across 8 versions & 1 rubygems

Version Path
cool.io-1.2.2 spec/dns_spec.rb
cool.io-1.2.1 spec/dns_spec.rb
cool.io-1.1.1 spec/dns_spec.rb
cool.io-1.2.0-x86-mswin32-60 spec/dns_spec.rb
cool.io-1.2.0-x86-mingw32 spec/dns_spec.rb
cool.io-1.2.0 spec/dns_spec.rb
cool.io-1.1.0 spec/dns_spec.rb
cool.io-1.0.0 spec/dns_spec.rb