Permalink
Browse files

Remove the entire Selenium RC and Local testing code

This breaks some serious compatibility, but all those old users are best
sticking with an older version of the gem because their usecase is a little
baroque nowadays (I don't think too highly of the RSpec/Test::Unit support
here).

Fixes #74
  • Loading branch information...
1 parent 6ba0b50 commit 000e00f6cd151aec94e476eafe2949ab6ffb6cf9 @rtyler rtyler committed Jun 7, 2012
Showing with 25 additions and 108 deletions.
  1. +2 −2 examples/rails3-demo/run-test.sh
  2. +0 −22 lib/sauce.rb
  3. +19 −67 lib/sauce/integrations.rb
  4. +4 −17 lib/sauce/selenium.rb
View
4 examples/rails3-demo/run-test.sh
@@ -28,8 +28,8 @@ require "test_helper"
class DemoTest < Sauce::RailsTestCase
test "my app", do
- page.open "/"
- assert page.is_text_present("Welcome aboard")
+ s.get 'http://localhost:3001/'
+ assert s.page_source.include? 'Welcome aboard'
end
end
EOF
View
22 lib/sauce.rb
@@ -7,26 +7,4 @@
require 'sauce/connect'
module Sauce
- @@cached_sessions = {}
-
- def self.cached_session(opts)
- @@cached_sessions[opts] or new_session(opts)
- end
-
- private
-
- def self.new_session(opts)
- session = nil
- if Sauce::Config.new.local?
- session = ::Selenium::Client::Driver.new(opts)
- else
- session = Sauce::Selenium.new(opts)
- end
- at_exit do
- session.stop
- end
- session.start
- @@cached_sessions[opts] = session
- return session
- end
end
View
86 lib/sauce/integrations.rb
@@ -17,7 +17,7 @@ def self.inherited(subclass)
before :suite do
config = Sauce::Config.new
if @@need_tunnel
- if config.application_host && !config.local?
+ if config.application_host
@@tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
@@tunnel.connect
@@tunnel.wait_until_ready
@@ -38,29 +38,11 @@ def execute(*args)
config = Sauce::Config.new
description = [self.class.description, self.description].join(" ")
config.browsers.each do |os, browser, version|
- if config.single_session?
- if config.local?
- @selenium = Sauce.cached_session(:host => "127.0.0.1", :port => 4444, :browser => "*" +
- browser, :url => "http://127.0.0.1:#{config.local_application_port}/")
- else
- @selenium = Sauce.cached_session({:os => os, :browser => browser, :browser_version => version,
- :job_name => self.class.description})
- end
- super(*args)
- else
- if config.local?
- @selenium = ::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,
- :job_name => "#{description}"})
- end
- @selenium.start_new_browser_session(:captureNetworkTraffic => config.capture_traffic?)
- super(*args)
- @selenium.stop
- end
+ @selenium = Sauce::Selenium2.new({:os => os, :browser => browser,
+ :browser_version => version,
+ :job_name => description})
+ super(*args)
+ @selenium.stop
end
end
@@ -89,16 +71,10 @@ def self.included(othermod)
config = Sauce::Config.new
description = the_test.metadata[:full_description]
config.browsers.each do |os, browser, version|
- if config.local?
- @selenium = ::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,
- :job_name => "#{description}"})
- end
- @selenium.start_new_browser_session(:captureNetworkTraffic => config.capture_traffic?)
+ @selenium = Sauce::Selenium2.new({:os => os,
+ :browser => browser,
+ :browser_version => version,
+ :job_name => description})
begin
the_test.run
ensure
@@ -116,7 +92,7 @@ def self.included(othermod)
config = Sauce::Config.new
files_to_run = ::RSpec.configuration.respond_to?(:files_to_run) ? ::RSpec.configuration.files_to_run :
::RSpec.configuration.settings[:files_to_run]
- if config.application_host && !config.local?
+ if config.application_host
need_tunnel = files_to_run.any? {|file| file =~ /spec\/selenium\//}
end
if need_tunnel
@@ -158,7 +134,7 @@ def run(*args, &blk)
end
unless my_name =~ /^default_test/
config = Sauce::Config.new
- if config.application_host && !config.local?
+ if config.application_host
unless ENV['TEST_ENV_NUMBER'].to_i > 1
Sauce::Connect.ensure_connected(:host => config.application_host, :port => config.application_port || 80)
end
@@ -177,37 +153,13 @@ def run(*args, &blk)
end
config.browsers.each do |os, browser, version|
- if config.single_session?
- if config.local?
- @browser = Sauce.cached_session(:host => "127.0.0.1", :port => 4444, :browser => "*" +
- browser, :url => "http://127.0.0.1:#{config.local_application_port}/")
- else
- options = self.class.sauce_config
- options.merge!({:os => os, :browser => browser, :browser_version => version,
- :job_name => "#{Rails.root.split[1].to_s} test suite"})
- @browser = Sauce.cached_session(options)
- end
- super(*args, &blk)
- else
- if config.local?
- @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
- options = self.class.sauce_config
- options.merge!({:os => os, :browser => browser, :browser_version => version,
- :job_name => "#{my_name}"})
- @browser = Sauce::Selenium.new(options)
- end
- if self.class.selenium_flags
- @browser.start_new_browser_session(self.class.selenium_flags.merge(:captureNetworkTraffic => config.capture_traffic?))
- else
- @browser.start_new_browser_session(:captureNetworkTraffic => config.capture_traffic?)
- end
- super(*args, &blk)
- @browser.stop
- end
+ options = self.class.sauce_config
+ options.merge!({:os => os, :browser => browser,
+ :browser_version => version,
+ :job_name => my_name.to_s})
+ @browser = Sauce::Selenium2.new(options)
+ super(*args, &blk)
+ @browser.stop
end
end
end
View
21 lib/sauce/selenium.rb
@@ -4,30 +4,17 @@
require 'selenium/webdriver/remote/http/persistent'
module Sauce
- class Selenium < ::Selenium::Client::Driver
- def initialize(opts={})
- @config = Sauce::Config.new(opts)
- super(opts.merge({:host => @config.host, :port => @config.port,
- :browser => @config.to_browser_string, :url => @config.browser_url}))
- end
-
- def passed!
- self.set_context "sauce:job-result=passed"
- end
-
- def failed!
- self.set_context "sauce:job-result=failed"
- end
- end
-
class Selenium2
attr_reader :config, :driver
def initialize(opts={})
@config = Sauce::Config.new(opts)
http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
http_client.timeout = 300 # Browser launch can take a while
- @driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@config.username}:#{@config.access_key}@#{@config.host}:#{@config.port}/wd/hub", :desired_capabilities => @config.to_desired_capabilities, :http_client => http_client)
+ @driver = ::Selenium::WebDriver.for(:remote,
+ :url => "http://#{@config.username}:#{@config.access_key}@#{@config.host}:#{@config.port}/wd/hub",
+ :desired_capabilities => @config.to_desired_capabilities,
+ :http_client => http_client)
http_client.timeout = 90 # Once the browser is up, commands should time out reasonably
end

0 comments on commit 000e00f

Please sign in to comment.