Class: Webrat::Selenium::MerbApplicationServer

Inherits:
ApplicationServer show all
Defined in:
lib/webrat/selenium/merb_application_server.rb

Instance Method Summary collapse

Methods inherited from ApplicationServer

boot, #boot, #prepare_pid_file, #stop_at_exit, #wait, #wait_for_socket

Instance Method Details

#failObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/webrat/selenium/merb_application_server.rb', line 18

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

#merb_commandObject



37
38
39
40
41
42
43
# File 'lib/webrat/selenium/merb_application_server.rb', line 37

def merb_command
  if File.exist?('bin/merb')
    merb_cmd = 'bin/merb'
  else
    merb_cmd = 'merb'
  end
end

#pid_fileObject



29
30
31
# File 'lib/webrat/selenium/merb_application_server.rb', line 29

def pid_file
  "log/merb.#{Webrat.configuration.application_port}.pid"
end

#startObject



6
7
8
# File 'lib/webrat/selenium/merb_application_server.rb', line 6

def start
  system start_command
end

#start_commandObject



33
34
35
# File 'lib/webrat/selenium/merb_application_server.rb', line 33

def start_command
  "#{merb_command} -d -p #{Webrat.configuration.application_port} -e #{Webrat.configuration.application_environment}"
end

#stopObject



10
11
12
13
14
15
16
# File 'lib/webrat/selenium/merb_application_server.rb', line 10

def stop
  silence_stream(STDOUT) do
    pid = File.read(pid_file)
    system("kill -9 #{pid}")
    FileUtils.rm_f pid_file
  end
end