spec/client_spec.rb in em-http-request-1.1.2 vs spec/client_spec.rb in em-http-request-1.1.3

- old
+ new

@@ -49,11 +49,11 @@ it "should raise error on invalid URL" do EventMachine.run { lambda { EventMachine::HttpRequest.new('random?text').get - }.should raise_error + }.should raise_error(Addressable::URI::InvalidURIError) EM.stop } end @@ -843,9 +843,36 @@ http.response_header["X-Custom-Header"].should == "foo" http.response_header["X_CUSTOM_HEADER"].should == "foo" EventMachine.stop } + } + end + + it "should close connection on invalid HTTP response" do + EventMachine.run { + response =<<-HTTP.gsub(/^ +/, '').strip + HTTP/1.1 403 Forbidden + Content-Type: text/plain + Content-Length: 13 + + Access Denied + + HTTP/1.1 403 Forbidden + Content-Type: text/plain + Content-Length: 13 + + Access Denied + HTTP + + @s = StubServer.new(response) + lambda { + conn = EventMachine::HttpRequest.new('http://127.0.0.1:8081/') + req = conn.get + req.errback { failed(http) } + req.callback { EM.stop } + }.should_not raise_error + } end context "User-Agent" do it 'should default to "EventMachine HttpClient"' do