Sha256: 05cd9e0cab90fdf03fd1160b9b87d70445ae65965fbbab77645c19c345119ced

Contents?: true

Size: 1.12 KB

Versions: 54

Compression:

Stored size: 1.12 KB

Contents

require "webrat/selenium/silence_stream"

module Webrat
  module Selenium
    module ApplicationServers
      class Base
        include Webrat::Selenium::SilenceStream

        def boot
          start
          wait
          stop_at_exit
        end

        def stop_at_exit
          at_exit do
            stop
          end
        end

        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

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

        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

      end
    end
  end
end

Version data entries

54 entries across 54 versions & 20 rubygems

Version Path
diabolo-webrat-0.5.1 lib/webrat/selenium/application_servers/base.rb
dstrelau-webrat-0.5.1 lib/webrat/selenium/application_servers/base.rb
emipair-webrat-0.0.1 lib/webrat/selenium/application_servers/base.rb
garnierjm-webrat-0.4.5 lib/webrat/selenium/application_servers/base.rb
hardbap-webrat-0.5.1 lib/webrat/selenium/application_servers/base.rb
hardbap-webrat-0.5.2 lib/webrat/selenium/application_servers/base.rb
winton-sum-0.1.0 vendor/webrat/lib/webrat/selenium/application_servers/base.rb
winton-sum-0.1.1 vendor/webrat/lib/webrat/selenium/application_servers/base.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/webrat-0.7.3/lib/webrat/selenium/application_servers/base.rb
indirect-webrat-0.7.5 lib/webrat/selenium/application_servers/base.rb
indirect-webrat-0.7.4 lib/webrat/selenium/application_servers/base.rb
webrat-0.7.3 lib/webrat/selenium/application_servers/base.rb
jbd-webrat-0.7.2.rails3 lib/webrat/selenium/application_servers/base.rb
webrat-0.7.2 lib/webrat/selenium/application_servers/base.rb
webrat-0.7.2.beta.2 lib/webrat/selenium/application_servers/base.rb
mutle-webrat-0.7.2.beta.1 lib/webrat/selenium/application_servers/base.rb
thoughtbot-webrat-0.7.2.pre lib/webrat/selenium/application_servers/base.rb
webrat-0.7.2.beta.1 lib/webrat/selenium/application_servers/base.rb
honkster-webrat-0.7.1.2 lib/webrat/selenium/application_servers/base.rb
honkster-webrat-0.7.1.1 lib/webrat/selenium/application_servers/base.rb