2 require File.dirname(__FILE__) + '/../ruby_lib/ebb'
14 Net::HTTP.get_response(URI.parse("http://0.0.0.0:#{TEST_PORT}#{path}"))
18 Net::HTTP.post_form(URI.parse("http://0.0.0.0:#{TEST_PORT}#{path}"), data)
23 commands = env['PATH_INFO'].split('/')
25 if commands.include?('bytes')
26 n = commands.last.to_i
27 raise "bytes called with n <= 0" if n <= 0
31 elsif commands.include?('test_post_length')
32 input_body = env['rack.input'].read
34 content_length_header = env['HTTP_CONTENT_LENGTH'].to_i
36 if content_length_header == input_body.length
37 body = "Content-Length matches input length"
40 body = "Content-Length header is #{content_length_header} but body length is #{input_body.length}"
46 body = "Undefined url"
49 [status, {'Content-Type' => 'text/plain'}, body]
53 class ServerTest < Test::Unit::TestCase
55 Thread.new { Ebb.start_server(HelperApp.new, :port => TEST_PORT) }
56 sleep 0.1 until Ebb.running?
61 sleep 0.1 while Ebb.running?