Use jasmine_selenium_runner to run specs via Sauce

This commit is contained in:
Gregg Van Hove and Rajan Agaskar
2013-09-25 10:45:04 -07:00
parent 5017d1a4f1
commit 84692f545c
6 changed files with 35 additions and 84 deletions

1
.gitignore vendored
View File

@@ -15,4 +15,5 @@ pkg/*
.sass-cache/*
src/html/.sass-cache/*
node_modules/
sauce_connect.log
*.swp

View File

@@ -16,32 +16,32 @@ matrix:
- TEST_COMMAND="bash travis-node-script.sh"
- env:
- JASMINE_BROWSER="firefox"
- SAUCE_PLATFORM="Linux"
- SAUCE_VERSION=''
- SAUCE_OS="Linux"
- SAUCE_BROWSER_VERSION=''
- env:
- JASMINE_BROWSER="safari"
- SAUCE_PLATFORM="OS X 10.8"
- SAUCE_VERSION=6
- SAUCE_OS="OS X 10.8"
- SAUCE_BROWSER_VERSION=6
- env:
- JASMINE_BROWSER="safari"
- SAUCE_PLATFORM="OS X 10.6"
- SAUCE_VERSION=5
- SAUCE_OS="OS X 10.6"
- SAUCE_BROWSER_VERSION=5
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_PLATFORM="Windows 8"
- SAUCE_VERSION=10
- SAUCE_OS="Windows 8"
- SAUCE_BROWSER_VERSION=10
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_PLATFORM="Windows 7"
- SAUCE_VERSION=9
- SAUCE_OS="Windows 7"
- SAUCE_BROWSER_VERSION=9
- env:
- JASMINE_BROWSER="internet explorer"
- SAUCE_PLATFORM="Windows 7"
- SAUCE_VERSION=8
- SAUCE_OS="Windows 7"
- SAUCE_BROWSER_VERSION=8
- env:
- JASMINE_BROWSER="chrome"
- SAUCE_PLATFORM="Linux"
- SAUCE_VERSION=''
- SAUCE_OS="Linux"
- SAUCE_BROWSER_VERSION=''
- env:
- JASMINE_BROWSER="phantomjs"
- USE_SAUCE=false

View File

@@ -2,12 +2,9 @@ require "bundler"
Bundler::GemHelper.install_tasks
require "json"
require "jasmine"
unless ENV["JASMINE_BROWSER"] == 'phantomjs'
require "jasmine_selenium_runner"
end
load "jasmine/tasks/jasmine.rake"
# TODO: Is there better way to invoke this using Jasmine gem???
desc "Run jasmine core specs in a browser."
task :core_spec do
exec "ruby spec/jasmine_self_test_spec.rb"
end
task :default => :core_spec

View File

@@ -1,63 +0,0 @@
require 'rubygems'
require 'bundler/setup'
require 'jasmine'
Jasmine.load_configuration_from_yaml(File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine.yml'))
config = Jasmine.config
browser = ENV['JASMINE_BROWSER'] || 'firefox'
if ENV['USE_SAUCE'] == 'true'
require 'selenium-webdriver'
unless ENV['TRAVIS_BUILD_NUMBER']
require 'sauce/connect'
# we want Sauce Connect locally, not on Travis
Sauce::Connect.connect!
end
username = ENV['SAUCE_USERNAME']
key = ENV['SAUCE_ACCESS_KEY']
platform = ENV['SAUCE_PLATFORM']
version = ENV['SAUCE_VERSION']
url = "http://#{username}:#{key}@localhost:4445/wd/hub"
config.port = 5555
capabilities = {
:platform => platform,
:version => version,
:build => ENV['TRAVIS_BUILD_NUMBER'],
:tags => [ENV['TRAVIS_RUBY_VERSION'], 'CI'],
:browserName => browser
}
capabilities.merge!('tunnel-identifier' => ENV['TRAVIS_JOB_NUMBER']) if ENV['TRAVIS_JOB_NUMBER']
webdriver = Selenium::WebDriver.for :remote, :url => url, :desired_capabilities => capabilities
end
config.webdriver = webdriver if webdriver
config.browser = browser if browser
config.runner = lambda { |formatter, jasmine_server_url| Jasmine::Runners::HTTP.new(formatter, jasmine_server_url, config) }
server = Jasmine::Server.new(config.port, Jasmine::Application.app(config))
t = Thread.new do
begin
server.start
rescue ChildProcess::TimeoutError
end
# # ignore bad exits
end
t.abort_on_exception = true
Jasmine::wait_for_listener(config.port, "jasmine server")
puts "jasmine server started."
formatters = config.formatters.map { |formatter_class| formatter_class.new(config) }
url = "#{config.host}:#{config.port}/"
runner = config.runner.call(Jasmine::Formatters::Multi.new(formatters), url)
runner.run
exit runner.succeeded? ? 0 : 1

View File

@@ -0,0 +1,16 @@
---
use_sauce: <%= ENV['USE_SAUCE'] %>
browser: <%= ENV['JASMINE_BROWSER'] %>
sauce:
name: jasmine-core <%= Time.now.to_s %>
username: <%= ENV['SAUCE_USERNAME'] %>
access_key: <%= ENV['SAUCE_ACCESS_KEY'] %>
build: <%= ENV['TRAVIS_BUILD_NUMBER'] || 'Ran locally' %>
tags:
- <%= ENV['TRAVIS_RUBY_VERSION'] || RUBY_VERSION %>
- CI
tunnel_identifier: <%= ENV['TRAVIS_JOB_NUMBER'] %>
os: <%= ENV['SAUCE_OS'] %>
browser_version: <%= ENV['SAUCE_BROWSER_VERSION'] %>

View File

@@ -9,4 +9,4 @@ then
curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
fi
bundle exec rake core_spec
bundle exec rake jasmine:ci