Permalink
Browse files

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 9da815a8795fdd3324e5d415a474aeebedd5de17
@@ -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
@@ -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.