~ubuntu-branches/ubuntu/natty/ruby1.8/natty-updates

« back to all changes in this revision

Viewing changes to test/webrick/utils.rb

  • Committer: Package Import Robot
  • Author(s): Daigo Moriwaki
  • Date: 2010-06-27 22:16:44 UTC
  • mfrom: (22.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20100627221644-7n8891uzqc17nvyq
Tags: 1.8.7.299-1
* New upstream release
* Removed patches that the upstrem has applied:
  - debian/patches/100312_timeout-fix.dpatch
  - debian/patches/100620_fix_pathname_warning.dpatch
  - debian/patches/100620_fix_super_called_outside_of_method.dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
  module_function
28
28
 
29
29
  def start_server(klass, config={}, &block)
 
30
    log_string = ""
 
31
    logger = Object.new
 
32
    class << logger; self; end.class_eval do
 
33
      define_method(:<<) {|msg| log_string << msg }
 
34
    end
 
35
    log = proc { "webrick log start:\n" + log_string.gsub(/^/, "  ").chomp + "\nwebrick log end" }
30
36
    server = klass.new({
31
37
      :BindAddress => "127.0.0.1", :Port => 0,
32
 
      :Logger => WEBrick::Log.new(NullWriter),
 
38
      :Logger => WEBrick::Log.new(logger),
33
39
      :AccessLog => [[NullWriter, ""]]
34
40
    }.update(config))
35
41
    begin
36
42
      thread = Thread.start{ server.start }
37
43
      addr = server.listeners[0].addr
38
 
      block.call([server, addr[3], addr[1]])
 
44
      block.call([server, addr[3], addr[1], log])
39
45
    ensure
40
46
      server.stop
41
47
      thread.join