Module: Sauce::JSUnit

Includes:
Utilities
Defined in:
lib/sauce/jsunit.rb,
lib/sauce/jsunit/run_utils.rb,
lib/sauce/jsunit/utilities.rb,
lib/sauce/jsunit/selenium_config.rb

Defined Under Namespace

Modules: Utilities Classes: RunUtils, SeleniumConfig

Instance Method Summary collapse

Methods included from Utilities

#debug, #diagnostics_prefix, #find_unused_port, #kill_mongrel_if_needed, #raise_with_message, #say, #setup_tunnel, #start_mongrel, #teardown_tunnel

Instance Method Details

#requiresObject



6
7
8
9
10
11
12
# File 'lib/sauce/jsunit.rb', line 6

def requires
  require 'sauce'
  require 'sauce/jsunit/run_utils'
  require 'sauce/jsunit/selenium_config'
  require "selenium/client"
  require 'lsof'
end

#run_jsunit_test(jsunit_params, options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sauce/jsunit.rb', line 33

def run_jsunit_test(jsunit_params, options = {})
  if $:.detect{ |x| x =~ /Selenium/}
    raise_with_message 'Selenium gem should not be in path! (deprecated in favor of selenium-client, which we require)'
  end

  default_jsunit_params = {
    :testPage => "/jsunit/javascripts/test-pages/suite.html",
    :autorun => "true",
    :setupPageTimeout => "60",
    :pageLoadTimeout => "60",
    :suppressCacheBuster => (@selenium_config.selenium_server_address == 'saucelabs.com').to_s
  }
  jsunit_params = default_jsunit_params.merge(jsunit_params)

  test_url = "/jsunit/javascripts/jsunit/jsunit/testRunner.html?" + jsunit_params.map { |k,v| "#{k}=#{v}" }.join("&")
  if @selenium_config.jsunit_polling_interval_seconds
    options = {:polling_interval => @selenium_config.jsunit_polling_interval_seconds}.merge(options)
  end
  run_suite(@selenium_driver, test_url, options)
end

#setup_jsunit_selenium(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sauce/jsunit.rb', line 14

def setup_jsunit_selenium(options = {})
  @diagnostics_prefix = '[SauceJSUnit]'
  requires
  @selenium_config = SeleniumConfig.new(ENV['SELENIUM_ENV'])
  start_app_server(options)
  @tunnel = Sauce::Connect.new(:port => 8080, :domain => "jsunit.test")
  @tunnel.wait_until_ready
  @selenium_driver = Sauce::Selenium.new(:job_name => "JSUnit", :browser_url=>"http://jsunit.test/", :'record-video' => false, :'record-screenshots' => false)
  debug "calling @selenium_driver.start"
  @selenium_driver.start_new_browser_session :trustAllSSLCertificates => false
  debug "@selenium_driver.start done"
end

#teardown_jsunit_seleniumObject



27
28
29
30
31
# File 'lib/sauce/jsunit.rb', line 27

def teardown_jsunit_selenium
  @selenium_driver.stop
  @tunnel.disconnect
  stop_app_server
end