Skip to content

Commit

Permalink
Make RailsTestCase a mixin
Browse files Browse the repository at this point in the history
This allows you to subclass something else and still mix in
our Selenium goodness.
  • Loading branch information
epall committed Jan 23, 2011
1 parent d3b5cea commit 2378bc9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/sauce/integrations.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -251,5 +252,9 @@ def run(*args, &blk)
def default_test
end
end

class RailsTestCase < ::ActiveSupport::TestCase
include SeleniumForTestUnit
end
end
end

0 comments on commit 2378bc9

Please sign in to comment.