File: dns_spec.rb

package info (click to toggle)
ruby-em-http-request 1.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 628 kB
  • ctags: 243
  • sloc: ruby: 3,478; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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('connection closed by server')
        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