moved application_server to appservers/base

This commit is contained in:
Mike Gaffney 2009-06-04 15:19:05 -05:00
parent 1910204974
commit dd8688f371
10 changed files with 51 additions and 53 deletions

View File

@ -1,45 +0,0 @@
module Webrat
module Selenium
class ApplicationServer
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 => Webrat.configuration.application_address,
: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

View File

@ -1,3 +1,4 @@
require "webrat/selenium/application_servers/base"
require "webrat/selenium/application_servers/sinatra"
require "webrat/selenium/application_servers/merb"
require "webrat/selenium/application_servers/rails"

View File

@ -0,0 +1,44 @@
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 => Webrat.configuration.application_address,
: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

View File

@ -1,7 +1,7 @@
module Webrat
module Selenium
module ApplicationServers
class External < ApplicationServer
class External < Webrat::Selenium::ApplicationServers::Base
def start
warn "Webrat Ignoring Start Of Application Server Due to External Mode"
end

View File

@ -1,7 +1,7 @@
module Webrat
module Selenium
module ApplicationServers
class Merb < ApplicationServer
class Merb < Webrat::Selenium::ApplicationServers::Base
def start
system start_command

View File

@ -1,8 +1,7 @@
module Webrat
module Selenium
module ApplicationServers
class Rails < ApplicationServer
class Rails < Webrat::Selenium::ApplicationServers::Base
def start
system start_command

View File

@ -1,7 +1,7 @@
module Webrat
module Selenium
module ApplicationServers
class Sinatra < ApplicationServer
class Sinatra < Webrat::Selenium::ApplicationServers::Base
def start
fork do

View File

@ -1,7 +1,7 @@
require "webrat/core/save_and_open_page"
require "webrat/selenium/selenium_rc_server"
require "webrat/selenium/application_server_factory"
require "webrat/selenium/application_server"
require "webrat/selenium/application_servers/base"
module Webrat
class TimeoutError < WebratError

View File

@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require "webrat/selenium/silence_stream"
require "webrat/selenium/application_server_factory"
require "webrat/selenium/application_server"
require "webrat/selenium/application_servers"

View File

@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require "webrat/selenium/application_server"
require "webrat/selenium/application_servers/base"
require "webrat/selenium/application_servers/external"
describe Webrat::Selenium::ApplicationServers::External do