From 2378bc9d009d23792e4aef6cddc348bec9692ece Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sat, 22 Jan 2011 20:31:27 -0800 Subject: [PATCH] Make RailsTestCase a mixin This allows you to subclass something else and still mix in our Selenium goodness. --- lib/sauce/integrations.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/sauce/integrations.rb b/lib/sauce/integrations.rb index 18025c5..9aa18f7 100644 --- a/lib/sauce/integrations.rb +++ b/lib/sauce/integrations.rb @@ -216,11 +216,12 @@ class Unit if defined?(ActiveSupport::TestCase) module Sauce - class RailsTestCase < ::ActiveSupport::TestCase - attr_reader :selenium + module SeleniumForTestUnit + attr_reader :browser - alias_method :page, :selenium - alias_method :s, :selenium + alias_method :page, :browser + alias_method :s, :browser + alias_method :selenium, :browser def run(*args, &blk) if self.respond_to? :name @@ -232,17 +233,17 @@ def run(*args, &blk) config = Sauce::Config.new config.browsers.each do |os, browser, version| if config.local? - @selenium = ::Selenium::Client::Driver.new(:host => "127.0.0.1", + @browser = ::Selenium::Client::Driver.new(:host => "127.0.0.1", :port => 4444, :browser => "*" + browser, :url => "http://127.0.0.1:#{config.local_application_port}/") else - @selenium = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version, + @browser = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version, :job_name => "#{my_name}"}) end - @selenium.start + @browser.start super(*args, &blk) - @selenium.stop + @browser.stop end end end @@ -251,5 +252,9 @@ def run(*args, &blk) def default_test end end + + class RailsTestCase < ::ActiveSupport::TestCase + include SeleniumForTestUnit + end end end