1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/testhelp.rb
zedshaw d7cc24df04 Win32 test and install fix-ups (cygwin)
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@218 19e92222-5c0b-0410-8929-a290d50e31e9
2006-05-30 23:36:48 +00:00

36 lines
737 B
Ruby

def redirect_test_io
orig_err = STDERR.dup
orig_out = STDOUT.dup
STDERR.reopen("test_stderr.log")
STDOUT.reopen("test_stdout.log")
begin
yield
ensure
STDERR.reopen(orig_err)
STDOUT.reopen(orig_out)
end
end
# Either takes a string to do a get request against, or a tuple of [URI, HTTP] where
# HTTP is some kind of Net::HTTP request object (POST, HEAD, etc.)
def hit(uris)
results = []
uris.each do |u|
res = nil
if u.kind_of? String
res = Net::HTTP.get(URI.parse(u))
else
url = URI.parse(u[0])
res = Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
end
assert res != nil, "Didn't get a response: #{u}"
results << res
end
return results
end