Sha256: 8692f2931b7f305ec832e1d83222b882dbef162f4a1ec78406489bcbe5d4a225

Contents?: true

Size: 1.21 KB

Versions: 14

Compression:

Stored size: 1.21 KB

Contents

require 'helper'

describe EventMachine::HttpRequest do

  it "should fail gracefully on an invalid host in Location header" do
    EventMachine.run {
      http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/redirect/badhost', :connect_timeout => 0.1).get :redirects => 1
      http.callback { failed(http) }
      http.errback {
        http.error.should match('unable to resolve server address')
        EventMachine.stop
      }
    }
  end

  it "should fail GET on DNS timeout" do
    EventMachine.run {
      EventMachine.heartbeat_interval = 0.1
      http = EventMachine::HttpRequest.new('http://127.1.1.1/', :connect_timeout => 0.1).get
      http.callback { failed(http) }
      http.errback {
        http.response_header.status.should == 0
        EventMachine.stop
      }
    }
  end

  it "should fail GET on invalid host" do
    EventMachine.run {
      EventMachine.heartbeat_interval = 0.1
      http = EventMachine::HttpRequest.new('http://somethinglocal/', :connect_timeout => 0.1).get
      http.callback { failed(http) }
      http.errback {
        http.error.should match(/unable to resolve server address/)
        http.response_header.status.should == 0
        EventMachine.stop
      }
    }
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
em-http-request-1.1.5 spec/dns_spec.rb
em-http-request-1.1.4 spec/dns_spec.rb
em-http-request-1.1.3 spec/dns_spec.rb
em-http-request-1.1.2 spec/dns_spec.rb
em-http-request-1.1.1 spec/dns_spec.rb
em-http-request-1.1.0 spec/dns_spec.rb
em-http-request-1.0.3 spec/dns_spec.rb
em-http-request-1.0.2 spec/dns_spec.rb
em-http-request-1.0.1 spec/dns_spec.rb
em-http-request-1.0.0 spec/dns_spec.rb
em-http-request-1.0.0.beta.4 spec/dns_spec.rb
em-http-request-1.0.0.beta.3 spec/dns_spec.rb
em-http-request-1.0.0.beta.2 spec/dns_spec.rb
em-http-request-1.0.0.beta.1 spec/dns_spec.rb