Skip to content

Instantly share code, notes, and snippets.

@imownbey
Created November 23, 2008 03:19
Show Gist options
  • Save imownbey/28019 to your computer and use it in GitHub Desktop.
Save imownbey/28019 to your computer and use it in GitHub Desktop.
class WebServerTest < Test::Unit::TestCase
def setup
@valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
@port = process_based_port
@tester = TestHandler.new
@app = Rack::URLMap.new('/test' => @tester)
redirect_test_io do
# We set num_processors=1 so that we can test the reaping code
@server = HttpServer.new("127.0.0.1", @port, @app, :num_processors => 1)
@server.start!
end
end
def teardown
redirect_test_io do
@server.stop(true)
end
end
def test_simple_server
hit(["http://localhost:#{@port}/test"])
assert @tester.ran_test, "Handler didn't really run"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment