Use jasmine_selenium_runner to run specs via Sauce
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,4 +15,5 @@ pkg/*
|
|||||||
.sass-cache/*
|
.sass-cache/*
|
||||||
src/html/.sass-cache/*
|
src/html/.sass-cache/*
|
||||||
node_modules/
|
node_modules/
|
||||||
|
sauce_connect.log
|
||||||
*.swp
|
*.swp
|
||||||
|
|||||||
28
.travis.yml
28
.travis.yml
@@ -16,32 +16,32 @@ matrix:
|
|||||||
- TEST_COMMAND="bash travis-node-script.sh"
|
- TEST_COMMAND="bash travis-node-script.sh"
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="firefox"
|
- JASMINE_BROWSER="firefox"
|
||||||
- SAUCE_PLATFORM="Linux"
|
- SAUCE_OS="Linux"
|
||||||
- SAUCE_VERSION=''
|
- SAUCE_BROWSER_VERSION=''
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="safari"
|
- JASMINE_BROWSER="safari"
|
||||||
- SAUCE_PLATFORM="OS X 10.8"
|
- SAUCE_OS="OS X 10.8"
|
||||||
- SAUCE_VERSION=6
|
- SAUCE_BROWSER_VERSION=6
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="safari"
|
- JASMINE_BROWSER="safari"
|
||||||
- SAUCE_PLATFORM="OS X 10.6"
|
- SAUCE_OS="OS X 10.6"
|
||||||
- SAUCE_VERSION=5
|
- SAUCE_BROWSER_VERSION=5
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="internet explorer"
|
- JASMINE_BROWSER="internet explorer"
|
||||||
- SAUCE_PLATFORM="Windows 8"
|
- SAUCE_OS="Windows 8"
|
||||||
- SAUCE_VERSION=10
|
- SAUCE_BROWSER_VERSION=10
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="internet explorer"
|
- JASMINE_BROWSER="internet explorer"
|
||||||
- SAUCE_PLATFORM="Windows 7"
|
- SAUCE_OS="Windows 7"
|
||||||
- SAUCE_VERSION=9
|
- SAUCE_BROWSER_VERSION=9
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="internet explorer"
|
- JASMINE_BROWSER="internet explorer"
|
||||||
- SAUCE_PLATFORM="Windows 7"
|
- SAUCE_OS="Windows 7"
|
||||||
- SAUCE_VERSION=8
|
- SAUCE_BROWSER_VERSION=8
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="chrome"
|
- JASMINE_BROWSER="chrome"
|
||||||
- SAUCE_PLATFORM="Linux"
|
- SAUCE_OS="Linux"
|
||||||
- SAUCE_VERSION=''
|
- SAUCE_BROWSER_VERSION=''
|
||||||
- env:
|
- env:
|
||||||
- JASMINE_BROWSER="phantomjs"
|
- JASMINE_BROWSER="phantomjs"
|
||||||
- USE_SAUCE=false
|
- USE_SAUCE=false
|
||||||
|
|||||||
9
Rakefile
9
Rakefile
@@ -2,12 +2,9 @@ require "bundler"
|
|||||||
Bundler::GemHelper.install_tasks
|
Bundler::GemHelper.install_tasks
|
||||||
require "json"
|
require "json"
|
||||||
require "jasmine"
|
require "jasmine"
|
||||||
|
unless ENV["JASMINE_BROWSER"] == 'phantomjs'
|
||||||
|
require "jasmine_selenium_runner"
|
||||||
|
end
|
||||||
load "jasmine/tasks/jasmine.rake"
|
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
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
|
|
||||||
16
spec/javascripts/support/jasmine_selenium_runner.yml
Normal file
16
spec/javascripts/support/jasmine_selenium_runner.yml
Normal 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'] %>
|
||||||
|
|
||||||
|
|
||||||
@@ -9,4 +9,4 @@ then
|
|||||||
curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
|
curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bundle exec rake core_spec
|
bundle exec rake jasmine:ci
|
||||||
|
|||||||
Reference in New Issue
Block a user