Module: Excon::Test::Plugin::Server::Webrick

Defined in:
lib/excon/test/plugin/server/webrick.rb

Instance Method Summary collapse

Instance Method Details

#start(app_str = app, bind_uri = bind) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/excon/test/plugin/server/webrick.rb', line 6

def start(app_str = app, bind_uri = bind)
  bind_uri = URI.parse(bind_uri) unless bind_uri.is_a? URI::Generic
  host = bind_uri.host.gsub(/[\[\]]/, '')
  port = bind_uri.port.to_s
  open_process('rackup', '-s', 'webrick', '--host', host, '--port', port, app_str)
  line = ''
  until line =~ /HTTPServer#start/
    line = error.gets
    fatal_time = elapsed_time > timeout
    raise 'webrick server has taken too long to start' if fatal_time
  end
  true
end