Skip to content

Commit

Permalink
moved application_server to appservers/base
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Gaffney committed Jun 4, 2009
1 parent 1910204 commit dd8688f
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 53 deletions.
45 changes: 0 additions & 45 deletions lib/webrat/selenium/application_server.rb

This file was deleted.

1 change: 1 addition & 0 deletions lib/webrat/selenium/application_servers.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
44 changes: 44 additions & 0 deletions lib/webrat/selenium/application_servers/base.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/webrat/selenium/application_servers/external.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/webrat/selenium/application_servers/merb.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Webrat
module Selenium
module ApplicationServers
class Merb < ApplicationServer
class Merb < Webrat::Selenium::ApplicationServers::Base

def start
system start_command
Expand Down
3 changes: 1 addition & 2 deletions lib/webrat/selenium/application_servers/rails.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module Webrat
module Selenium

module ApplicationServers
class Rails < ApplicationServer
class Rails < Webrat::Selenium::ApplicationServers::Base

def start
system start_command
Expand Down
2 changes: 1 addition & 1 deletion lib/webrat/selenium/application_servers/sinatra.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Webrat
module Selenium
module ApplicationServers
class Sinatra < ApplicationServer
class Sinatra < Webrat::Selenium::ApplicationServers::Base

def start
fork do
Expand Down
2 changes: 1 addition & 1 deletion lib/webrat/selenium/selenium_session.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion spec/public/selenium/application_server_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require "webrat/selenium/silence_stream"
require "webrat/selenium/application_server_factory"
require "webrat/selenium/application_server"

require "webrat/selenium/application_servers"

Expand Down
2 changes: 1 addition & 1 deletion spec/public/selenium/application_servers/external_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit dd8688f

Please sign in to comment.