Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add code to start an app server for any Rack app via rackup
  • Loading branch information
brynary committed Jul 24, 2010
1 parent 5c382a5 commit 9da815a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/webrat/selenium/application_server_factory.rb
Expand Up @@ -14,6 +14,9 @@ def self.app_server_instance
when :rails
require "webrat/selenium/application_servers/rails"
return Webrat::Selenium::ApplicationServers::Rails.new
when :rack
require "webrat/selenium/application_servers/rack"
return Webrat::Selenium::ApplicationServers::Rack.new
when :external
require "webrat/selenium/application_servers/external"
return Webrat::Selenium::ApplicationServers::External.new
Expand Down
36 changes: 36 additions & 0 deletions lib/webrat/selenium/application_servers/rack.rb
@@ -0,0 +1,36 @@
require "webrat/selenium/application_servers/base"

module Webrat
module Selenium
module ApplicationServers
class Rack < Webrat::Selenium::ApplicationServers::Base

def start
@pid = fork do
exec start_command
end
end

def stop
Process.kill("TERM", @pid)
end

def fail
$stderr.puts
$stderr.puts
$stderr.puts "==> Failed to boot the application server... exiting!"
$stderr.puts
$stderr.puts "Verify you can start a server on port #{Webrat.configuration.application_port} with the following command:"
$stderr.puts
$stderr.puts " #{start_command}"
exit
end

def start_command
"rackup --port #{Webrat.configuration.application_port} --env #{Webrat.configuration.application_environment}"
end

end
end
end
end

0 comments on commit 9da815a

Please sign in to comment.