Parent

Namespace

Capybara::Server

Attributes

app[R]
port[R]

Public Class Methods

new(app) click to toggle source
# File lib/capybara/server.rb, line 22
def initialize(app)
  @app = app
end

Public Instance Methods

boot() click to toggle source
# File lib/capybara/server.rb, line 57
def boot
  return self unless @app
  find_available_port
  Capybara.log "application has already booted" and return self if responsive?
  Capybara.log "booting Rack applicartion on port #{port}"

  Thread.new do
    handler.run(Identify.new(@app), :Port => port, :AccessLog => [])
  end
  Capybara.log "checking if application has booted"

  Capybara::WaitUntil.timeout(10) do
    if responsive?
      Capybara.log("application has booted")
      true
    else
      sleep 0.5
      false
    end
  end
  self
rescue Timeout::Error
  Capybara.log "Rack application timed out during boot"
  exit
end
handler() click to toggle source
# File lib/capybara/server.rb, line 42
def handler
  begin
    require 'rack/handler/thin'
    Rack::Handler::Thin
  rescue LoadError
    begin
      require 'rack/handler/mongrel'
      Rack::Handler::Mongrel
    rescue LoadError
      require 'rack/handler/webrick'
      Rack::Handler::WEBrick
    end
  end
end
host() click to toggle source
# File lib/capybara/server.rb, line 26
def host
  "localhost" 
end
responsive?() click to toggle source
# File lib/capybara/server.rb, line 38
def responsive?
  is_running_on_port?(port)
end
url(path) click to toggle source
# File lib/capybara/server.rb, line 30
def url(path)
  if path =~ /^http/
    path
  else
    (Capybara.app_host || "http://#{host}:#{port}") + path.to_s
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.