M
Michael Neumann
--------------010507070100020004070402
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Could the appended file be added to the Ruby distribution as
lib/webrick/testing.rb? It's currently there as
test/xmlrpc/webrick_testing.rb.
I think it's quite useful to test webrick servlets without the need for
mock objects.
Regards,
Michael
--------------010507070100020004070402
Content-Type: text/plain;
name="webrick_testing.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="webrick_testing.rb"
require 'timeout'
module WEBrick_Testing
class DummyLog < WEBrick::BasicLog
def initialize() super(self) end
def <<(*args) end
end
def start_server(config={})
raise "already started" if @__server_pid or @__started
trap('HUP') { @__started = true }
@__server_pid = fork {
w = WEBrick::HTTPServer.new(
{
:Logger => DummyLog.new,
:AccessLog => [],
:StartCallback => proc { Process.kill('HUP', Process.ppid) }
}.update(config))
yield w
trap('INT') { w.shutdown }
w.start
exit
}
Timeout.timeout(5) {
nil until @__started # wait until the server is ready
}
end
def stop_server
Process.kill('INT', @__server_pid)
@__server_pid = nil
@__started = false
Process.wait
raise unless $?.success?
end
end
--------------010507070100020004070402--
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Could the appended file be added to the Ruby distribution as
lib/webrick/testing.rb? It's currently there as
test/xmlrpc/webrick_testing.rb.
I think it's quite useful to test webrick servlets without the need for
mock objects.
Regards,
Michael
--------------010507070100020004070402
Content-Type: text/plain;
name="webrick_testing.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="webrick_testing.rb"
require 'timeout'
module WEBrick_Testing
class DummyLog < WEBrick::BasicLog
def initialize() super(self) end
def <<(*args) end
end
def start_server(config={})
raise "already started" if @__server_pid or @__started
trap('HUP') { @__started = true }
@__server_pid = fork {
w = WEBrick::HTTPServer.new(
{
:Logger => DummyLog.new,
:AccessLog => [],
:StartCallback => proc { Process.kill('HUP', Process.ppid) }
}.update(config))
yield w
trap('INT') { w.shutdown }
w.start
exit
}
Timeout.timeout(5) {
nil until @__started # wait until the server is ready
}
end
def stop_server
Process.kill('INT', @__server_pid)
@__server_pid = nil
@__started = false
Process.wait
raise unless $?.success?
end
end
--------------010507070100020004070402--