Sha256: 3ddd7594155b3bd2fb8d01444ceb28b5e3f98d6395bf7a6180ac1eb3e20187d7
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require 'capybara' require 'uri' $uri = URI.parse Capybara.app_host || "" module Sauce module Capybara class Driver < ::Capybara::Selenium::Driver def browser unless @browser puts "[Connecting to Sauce OnDemand...]" config = Sauce::Config.new @domain = "#{rand(10000)}.test" @sauce_tunnel = Sauce::Connect.new(:host => $uri.host || rack_server.host, :port => $uri.port || rack_server.port, :domain => @domain, :quiet => true) @sauce_tunnel.wait_until_ready @browser = Sauce::Selenium2.new(:name => "Capybara test", :browser_url => "http://#{@domain}") at_exit do @browser.quit @sauce_tunnel.disconnect end end @browser end private def url(path) if path =~ /^http/ path else "http://#{@domain}#{path}" end end end end end Capybara.register_driver :sauce do |app| Sauce::Capybara::Driver.new(app) end # Monkeypatch Capybara to not use :selenium driver require 'capybara/dsl' module Capybara def self.javascript_driver @javascript_driver || :sauce end end # Switch Cucumber stories tagged with @selenium to use sauce begin Before("@selenium") do Capybara.current_driver = :sauce end rescue NoMethodError end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sauce-1.0.2 | lib/sauce/capybara.rb |