Skip to content

Commit

Permalink
small doc fixup to explain how to use different application framework…
Browse files Browse the repository at this point in the history
…s with selenium
  • Loading branch information
atmos committed Feb 23, 2009
1 parent ec06c76 commit 120a53d
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions lib/webrat/selenium.rb
Expand Up @@ -32,8 +32,12 @@ def self.pid_file
prepare_pid_file("#{RAILS_ROOT}/tmp/pids", "mongrel_selenium.pid")
end
end

def self.start_app_server #:nodoc:
# Start the appserver for the underlying framework to test
#
# Sinatra: requires a config.ru in the root of your sinatra app to use this
# Merb: Attempts to use bin/merb and falls back to the system merb
# Rails: Calls mongrel_rails to startup the appserver
def self.start_app_server
case Webrat.configuration.application_framework
when :sinatra
fork do
Expand All @@ -52,7 +56,12 @@ def self.start_app_server #:nodoc:
TCPSocket.wait_for_service :host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i
end

def self.stop_app_server #:nodoc:
# Stop the appserver for the underlying framework under test
#
# Sinatra: Reads and kills the pid from the pid file created on startup
# Merb: Reads and kills the pid from the pid file created on startup
# Rails: Calls mongrel_rails stop to kill the appserver
def self.stop_app_server
case Webrat.configuration.application_framework
when :sinatra
pid = File.read('rack.pid')
Expand Down Expand Up @@ -91,11 +100,25 @@ def self.prepare_pid_file(file_path, pid_file_name)
# selenium.dragdrop("id=photo_123", "+350, 0")
# end
#
# == Auto-starting of the mongrel and java server
# == Choosing the underlying framework to test
#
# Webrat assumes you're using rails by default but it can also work with sinatra
# and merb. To take advantage of this you can use the configuration block to
# set the application_framework variable.
# require "webrat"
#
# Webrat.configure do |config|
# config.mode = :selenium
# config.application_port = 4567
# config.application_framework = :sinatra # could also be :merb
# end
#
# == Auto-starting of the appserver and java server
#
# Webrat will automatically start the Selenium Java server process and an instance
# of Mongrel when a test is run. The Mongrel will run in the "selenium" environment
# instead of "test", so ensure you've got that defined, and will run on port 3001.
# instead of "test", so ensure you've got that defined, and will run on port
# Webrat.configuration.application_port.
#
# == Waiting
#
Expand Down

0 comments on commit 120a53d

Please sign in to comment.