Class: Webrat::Selenium::ApplicationServers::Base

Inherits:
Object
  • Object
show all
Includes:
SilenceStream
Defined in:
lib/webrat/selenium/application_servers/base.rb

Direct Known Subclasses

External, Merb, Rails, Sinatra

Instance Method Summary collapse

Methods included from SilenceStream

#silence_stream

Constructor Details

#initializeBase

Returns a new instance of Base.



9
10
11
# File 'lib/webrat/selenium/application_servers/base.rb', line 9

def initialize
  @shell = Nautilus::Shell.new
end

Instance Method Details

#bootObject



13
14
15
16
17
# File 'lib/webrat/selenium/application_servers/base.rb', line 13

def boot
  start
  wait
  stop_at_exit
end

#prepare_pid_file(file_path, pid_file_name) ⇒ Object



42
43
44
45
# File 'lib/webrat/selenium/application_servers/base.rb', line 42

def prepare_pid_file(file_path, pid_file_name)
  FileUtils.mkdir_p File.expand_path(file_path)
  File.expand_path("#{file_path}/#{pid_file_name}")
end

#stop_at_exitObject



19
20
21
22
23
# File 'lib/webrat/selenium/application_servers/base.rb', line 19

def stop_at_exit
  at_exit do
    stop
  end
end

#waitObject



25
26
27
28
29
# File 'lib/webrat/selenium/application_servers/base.rb', line 25

def wait
  $stderr.print "==> Waiting for #{Webrat.configuration.application_framework} application server on port #{Webrat.configuration.application_port}... "
  wait_for_socket
  $stderr.print "Ready!\n"
end

#wait_for_socketObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/webrat/selenium/application_servers/base.rb', line 31

def wait_for_socket
  silence_stream(STDOUT) do
    TCPSocket.wait_for_service_with_timeout \
      :host     => "127.0.0.1",
      :port     => Webrat.configuration.application_port.to_i,
      :timeout  => 30 # seconds
  end
  rescue SocketError
  fail
end

#windows?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/webrat/selenium/application_servers/base.rb', line 47

def windows?
  RUBY_PLATFORM =~ /mswin/
end