Sha256: 4b967e266513d2ac53ca7c093f4ff5720cc35202ea2f877fb105dff957cbbfdf

Contents?: true

Size: 725 Bytes

Versions: 22

Compression:

Stored size: 725 Bytes

Contents

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
mongrel-0.2.1 test/test_ws.rb
mongrel-0.2.0 test/test_ws.rb
mongrel-0.3.1 test/test_ws.rb
mongrel-0.3.10.1 test/test_ws.rb
mongrel-0.2.2 test/test_ws.rb
mongrel-0.3.12.3 test/test_ws.rb
mongrel-0.3.11 test/test_ws.rb
mongrel-0.3.10 test/test_ws.rb
mongrel-0.3.12.1 test/test_ws.rb
mongrel-0.3.12.2 test/test_ws.rb
mongrel-0.3.12 test/test_ws.rb
mongrel-0.3.12.4 test/test_ws.rb
mongrel-0.3.7 test/test_ws.rb
mongrel-0.3.6 test/test_ws.rb
mongrel-0.3.2 test/test_ws.rb
mongrel-0.3.3 test/test_ws.rb
mongrel-0.3.4 test/test_ws.rb
mongrel-0.3.7.1 test/test_ws.rb
mongrel-0.3.8 test/test_ws.rb
mongrel-0.3.5 test/test_ws.rb