Sha256: 0f78f958957e857e007454c65708b2577065f5f5a43054c3a8dd6349b3b6e811
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'test/unit' require 'pp' begin require 'rubygems' rescue LoadError end module Enumerable unless self.methods.include? :count def count self.inject(0){|i,_| i + 1} end end end class Test::Unit::TestCase def data_on_port(data, port) Thread.abort_on_exception = true thrd = Thread.new do require "webrick" l = WEBrick::Log.new(STDOUT, WEBrick::BasicLog::WARN) server = WEBrick::HTTPServer.new( :Port => port, :Logger => l #, #:AccessLog => l # TODO - disable the access log, somehow ) #server.logger.level = WEBrick::BasicLog::WARN #pp server.logger begin server.mount_proc("/") do |req,resp| resp.body = data.to_str end server.start ensure server.shutdown end end # Wait for server socket to come up while true begin s = TCPSocket.new("127.0.0.1", port) s.close() rescue Errno::ECONNREFUSED next end return thrd end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thoughtafter-vpim-0.7.0.1 | test/common.rb |