1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

don't let integration tests block indefinitely

This commit is contained in:
Konstantin Haase 2012-03-18 10:16:59 +01:00
parent df317cfde6
commit fbdb25bb0d
2 changed files with 3 additions and 3 deletions

View file

@ -2,6 +2,7 @@ require 'sinatra/base'
require 'rbconfig'
require 'open-uri'
require 'net/http'
require 'timeout'
module IntegrationHelper
class BaseServer
@ -65,7 +66,7 @@ module IntegrationHelper
def alive?
3.times { get('/ping') }
true
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError => error
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError, Timeout::Error => error
false
end
@ -79,7 +80,7 @@ module IntegrationHelper
end
def get(url)
open("http://127.0.0.1:#{port}#{url}").read
Timeout.timeout(1) { open("http://127.0.0.1:#{port}#{url}").read }
end
def log

View file

@ -1,6 +1,5 @@
require File.expand_path('../helper', __FILE__)
require File.expand_path('../integration_helper', __FILE__)
require 'timeout'
# These tests start a real server and talk to it over TCP.
# Every test runs with every detected server.