From 6d74cd935e0857b7b4fd650429901075d38fe223 Mon Sep 17 00:00:00 2001 From: Mike Gaffney Date: Thu, 4 Jun 2009 15:03:00 -0500 Subject: [PATCH] [#246 state:resolved] added external application server if you have your own started --- .../selenium/application_server_factory.rb | 3 +++ lib/webrat/selenium/application_servers.rb | 4 ++++ .../selenium/application_servers/external.rb | 24 +++++++++++++++++++ .../application_server_factory_spec.rb | 12 +++++++--- .../application_servers/external_spec.rb | 12 ++++++++++ 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 lib/webrat/selenium/application_servers.rb create mode 100644 lib/webrat/selenium/application_servers/external.rb create mode 100644 spec/public/selenium/application_servers/external_spec.rb diff --git a/lib/webrat/selenium/application_server_factory.rb b/lib/webrat/selenium/application_server_factory.rb index d56565b..76f3dfe 100644 --- a/lib/webrat/selenium/application_server_factory.rb +++ b/lib/webrat/selenium/application_server_factory.rb @@ -14,6 +14,9 @@ module Webrat when :rails require "webrat/selenium/rails_application_server" return RailsApplicationServer.new + when :external + require "webrat/selenium/application_servers/external" + return Webrat::Selenium::ApplicationServers::External.new else raise WebratError.new(<<-STR) Unknown Webrat application_framework: #{Webrat.configuration.application_framework.inspect} diff --git a/lib/webrat/selenium/application_servers.rb b/lib/webrat/selenium/application_servers.rb new file mode 100644 index 0000000..59c68ac --- /dev/null +++ b/lib/webrat/selenium/application_servers.rb @@ -0,0 +1,4 @@ +require "webrat/selenium/sinatra_application_server" +require "webrat/selenium/merb_application_server" +require "webrat/selenium/rails_application_server" +require "webrat/selenium/application_servers/external" \ No newline at end of file diff --git a/lib/webrat/selenium/application_servers/external.rb b/lib/webrat/selenium/application_servers/external.rb new file mode 100644 index 0000000..187cfff --- /dev/null +++ b/lib/webrat/selenium/application_servers/external.rb @@ -0,0 +1,24 @@ +module Webrat + module Selenium + module ApplicationServers + class External < ApplicationServer + def start + warn "Webrat Ignoring Start Of Application Server Due to External Mode" + end + + def stop + end + + def fail + end + + def pid_file + end + + def wait + end + + end + end + end +end \ No newline at end of file diff --git a/spec/public/selenium/application_server_factory_spec.rb b/spec/public/selenium/application_server_factory_spec.rb index a709863..ceae5e1 100644 --- a/spec/public/selenium/application_server_factory_spec.rb +++ b/spec/public/selenium/application_server_factory_spec.rb @@ -4,9 +4,7 @@ require "webrat/selenium/silence_stream" require "webrat/selenium/application_server_factory" require "webrat/selenium/application_server" -require "webrat/selenium/sinatra_application_server" -require "webrat/selenium/merb_application_server" -require "webrat/selenium/rails_application_server" +require "webrat/selenium/application_servers" describe Webrat::Selenium::ApplicationServerFactory do @@ -34,6 +32,14 @@ describe Webrat::Selenium::ApplicationServerFactory do Webrat::Selenium::ApplicationServerFactory.app_server_instance end + it "should require and create a rails server in external mode" do + server = mock(Webrat::Selenium::ApplicationServers::External) + Webrat.configuration.application_framework = :external + Webrat::Selenium::ApplicationServerFactory.should_receive(:require).with("webrat/selenium/application_servers/external") + Webrat::Selenium::ApplicationServers::External.should_receive(:new).and_return(server) + Webrat::Selenium::ApplicationServerFactory.app_server_instance + end + it "should handle unknown servers with an exception in unknown modes" do Webrat.configuration.application_framework = :unknown lambda { diff --git a/spec/public/selenium/application_servers/external_spec.rb b/spec/public/selenium/application_servers/external_spec.rb new file mode 100644 index 0000000..7c3faca --- /dev/null +++ b/spec/public/selenium/application_servers/external_spec.rb @@ -0,0 +1,12 @@ +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') + +require "webrat/selenium/application_server" +require "webrat/selenium/application_servers/external" + +describe Webrat::Selenium::ApplicationServers::External do + + it "should just boot up with no exceptions" do + Webrat::Selenium::ApplicationServers::External.new.boot + end + +end