Class: Webrat::Selenium::ApplicationServers::Rails

Inherits:
Base
  • Object
show all
Defined in:
lib/webrat/selenium/application_servers/rails.rb

Instance Method Summary collapse

Methods inherited from Base

#boot, #initialize, #prepare_pid_file, #stop_at_exit, #wait, #wait_for_socket, #windows?

Methods included from SilenceStream

#silence_stream

Constructor Details

This class inherits a constructor from Webrat::Selenium::ApplicationServers::Base

Instance Method Details

#failObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/webrat/selenium/application_servers/rails.rb', line 25

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

#install_serviceObject



40
41
42
# File 'lib/webrat/selenium/application_servers/rails.rb', line 40

def install_service
  "mongrel_rails service::install -N testapp -c #{RAILS_ROOT} -p #{Webrat.configuration.application_port} -e test"
end

#pid_fileObject



36
37
38
# File 'lib/webrat/selenium/application_servers/rails.rb', line 36

def pid_file
  prepare_pid_file("#{RAILS_ROOT}/tmp/pids", "mongrel_selenium.pid")
end

#remove_serviceObject



44
45
46
# File 'lib/webrat/selenium/application_servers/rails.rb', line 44

def remove_service
  "mongrel_rails service::remove -N testapp"
end

#startObject



8
9
10
11
12
13
14
# File 'lib/webrat/selenium/application_servers/rails.rb', line 8

def start
  if windows?
    @shell.run remove_service, {:background => true }
    @shell.run install_service, {:background => false }
  end
  @shell.run start_command, {:background => true}
end

#start_commandObject



48
49
50
51
52
53
54
# File 'lib/webrat/selenium/application_servers/rails.rb', line 48

def start_command
  if windows?
    "net start testapp"
  else 
    "mongrel_rails start -d --chdir='#{RAILS_ROOT}' --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file}"
  end
end

#stopObject



16
17
18
19
20
21
22
23
# File 'lib/webrat/selenium/application_servers/rails.rb', line 16

def stop
  silence_stream(STDOUT) do
    @shell.run stop_command, {:background => false}
    if windows?
      @shell.run remove_service, {:background => false }
    end
  end
end

#stop_commandObject



56
57
58
59
60
61
62
# File 'lib/webrat/selenium/application_servers/rails.rb', line 56

def stop_command
  if windows?
    "net stop testapp"
 else
    "mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
  end
end