1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/test_ws.rb
zedshaw 004dec2c2f initial import into trunk
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@4 19e92222-5c0b-0410-8929-a290d50e31e9
2006-01-28 19:03:53 +00:00

33 lines
725 B
Ruby

require 'test/unit'
require 'net/http'
require 'mongrel'
require 'timeout'
include Mongrel;
class TestHandler < Mongrel::HttpHandler
attr_reader :ran_test
def process(request, response)
@ran_test = true
response.socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello!\n")
end
end
class WSTest < Test::Unit::TestCase
def test_simple_server
h = HttpServer.new("0.0.0.0", 9998)
tester = TestHandler.new
h.register("/test", tester)
h.run
sleep(1)
res = Net::HTTP.get(URI.parse('http://localhost:9998/test'))
assert res != nil, "Didn't get a response"
assert tester.ran_test, "Handler didn't really run"
end
end