Sha256: ccb6c1a9a971904392348130d869b417f91b342b2a803bedbad2810d0ded5214
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require 'test/unit' require 'pp' $:.unshift File.dirname(__FILE__) + "/../lib" 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 |
---|---|
scashin133-vpim-9.4.0 | test/common.rb |