jasmine_selenium_runner 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f85e4cefa20dc2a1976e3a56c9ab6f69abaceaf8
4
+ data.tar.gz: eba4354fd76bc9642d63bb5c33b0adc283dcd21d
5
+ SHA512:
6
+ metadata.gz: b92bb57994b870683782005d394899af5bf11a896659d3c54578b849ea14f55047750e39b32d517988c9d0bf145359719c88ac0c7b27ae7805778fc88bf896e6
7
+ data.tar.gz: 11a5f427662ff9c31063be536da4988a7b7ab271d8d67410c0e664edd97dfcf8b31211a0b1b9e251d413845e2fa526089486964490f7c2d687a1214451cf5057
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ before_script:
2
+ - sh -e /etc/init.d/xvfb start
3
+ - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
4
+ script: DISPLAY=:99.0 bundle exec rake
5
+ rvm:
6
+ - 2.0.0
7
+ env:
8
+ global:
9
+ - secure: i8arxYVwMt/vp8a5RugpE+edkCg1G+wQ1WdCbdiKPhDZEcMh6f9vETvcsY9W94xY7yTBNSrZ+jNkz5ZQrGfiq1HllKxSjZBXv0pJ+wyxuFHl7hSib1OCzEImk0lHVryX7A7iO4u1GzZ+jmiVyKL7uEjD6CokphOpwnYpBln8jlg=
10
+ - secure: UWmQafzVbXw81vu+V8FJdu0ArVSpT/Ya+iFOVksDoatxyuJzS+BRXOjXuOL1mEo6CwpIhxo5Fs+8ALC/K8fTvSRos4hsRdkb38Gddyj5M7fSeICzeBMejUcu+4b1QO98AnN6uRqbFtNgm3c2qx448tLIp4sKKmGNro6lAD+Txew=
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git'
5
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Pivotal Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Jasmine Selenium Runner [![Build Status](https://travis-ci.org/jasmine/jasmine_selenium_runner.png?branch=master)](https://travis-ci.org/jasmine/jasmine_selenium_runner)
2
+
3
+ Runner for building Jasmine builds in Selenium (permitting automatic cross-browser testing).
4
+ After require-ing, jasmine_selenium_runner automatically sets itself up as the jasmine:ci runner.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile (to test & dev groups):
9
+
10
+ gem 'jasmine_selenium_runner'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install jasmine_selenium_runner
19
+
20
+ ### Basic Usage:
21
+
22
+ - In rails, simply `run rake jasmine:ci`, tests should run in firefox.
23
+ - Outside of rails, you may need to add `require 'jasmine_selenium_runner'` to your Rakefile after jasmine is required.
24
+
25
+ ### Using w/ Travis (with xvfb):
26
+
27
+ You'll want your .travis.yml file to look like the following:
28
+
29
+ before_script:
30
+ - sh -e /etc/init.d/xvfb start
31
+ script: DISPLAY=:99.0 bundle exec rake jasmine:ci
32
+ env:
33
+ global:
34
+ - JASMINE_BROWSER=firefox
35
+
36
+ ### Using SauceLabs w/ Travis to run in multiple browsers:
37
+
38
+ Create a jasmine_selenium_runner.yml in spec/javascripts/support/ with the following content:
39
+
40
+ ---
41
+ use_sauce: <%= ENV['USE_SAUCE'] %>
42
+ browser: <%= ENV['JASMINE_BROWSER'] %>
43
+ sauce:
44
+ name: some-project-name <%= Time.now.to_s %>
45
+ username: <%= ENV['SAUCE_USERNAME'] %>
46
+ access_key: <%= ENV['SAUCE_ACCESS_KEY'] %>
47
+ build: <%= ENV['TRAVIS_BUILD_NUMBER'] || 'Ran locally' %>
48
+ tags:
49
+ - <%= ENV['TRAVIS_RUBY_VERSION'] || RUBY_VERSION %>
50
+ - CI
51
+ tunnel_identifier: <%= ENV['TRAVIS_JOB_NUMBER'] ? "#{ENV['TRAVIS_JOB_NUMBER']}" : nil %>
52
+ os: <%= ENV['SAUCE_OS'] %>
53
+ browser_version: <%= ENV['SAUCE_BROWSER_VERSION'] %>
54
+
55
+ Here's a compatible .travis.yml example (Travis has
56
+ [instructions for secure environment variables](http://about.travis-ci.org/docs/user/build-configuration/#Secure-environment-variables)
57
+ which you'll want for SAUCE_USERNAME and SAUCE_ACCESS_KEY):
58
+
59
+ before_script:
60
+ - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
61
+ script: bundle exec rake jasmine:ci
62
+ rvm:
63
+ - 2.0.0
64
+ env:
65
+ global:
66
+ - USE_SAUCE=true
67
+ - secure: some-secure-env-var
68
+ - secure: some-other-secure-env-var
69
+ matrix:
70
+ include:
71
+ - env:
72
+ - JASMINE_BROWSER="firefox"
73
+ - SAUCE_OS="Linux"
74
+ - SAUCE_BROWSER_VERSION=''
75
+ - env:
76
+ - JASMINE_BROWSER="safari"
77
+ - SAUCE_OS="OS X 10.8"
78
+ - SAUCE_BROWSER_VERSION=6
79
+ - env:
80
+ - JASMINE_BROWSER="internet explorer"
81
+ - SAUCE_OS="Windows 8"
82
+ - SAUCE_BROWSER_VERSION=10
83
+ - env:
84
+ - env:
85
+ - JASMINE_BROWSER="chrome"
86
+ - SAUCE_OS="Linux"
87
+ - SAUCE_BROWSER_VERSION=''
88
+
89
+ ### Using with a custom selenium server
90
+
91
+ Create a jasmine_selenium_runner.yml in spec/javascripts/support/ with the following content:
92
+
93
+ ---
94
+ selenium_server: <full url to selenium server>
95
+ browser: <%= ENV['JASMINE_BROWSER'] %>
96
+
97
+ ## Contributing
98
+
99
+ 1. Fork it
100
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
101
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
102
+ 4. Push to the branch (`git push origin my-new-feature`)
103
+ 5. Create new Pull Request
104
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run all specs in spec directory (excluding plugin specs)"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jasmine/runners/selenium/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jasmine_selenium_runner"
8
+ spec.version = Jasmine::Runners::Selenium::VERSION
9
+ spec.authors = ["Rajan Agaskar", "Gregg Van Hove" ]
10
+ spec.email = ["rajan@pivotallabs.com", 'gvanhove@pivotallabs.com']
11
+ spec.description = %q{Run your jasmine tests in a real live browser!}
12
+ spec.summary = %q{Run your jasmine tests in a real live browser!}
13
+ spec.homepage = "http://pivotal.github.com/jasmine/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'rails'
25
+ spec.add_dependency 'jasmine', '~> 2.0.0.alpha'
26
+ spec.add_dependency 'selenium-webdriver', '~> 2.35'
27
+ spec.add_dependency 'sauce-connect'
28
+ end
@@ -0,0 +1,8 @@
1
+ module Jasmine
2
+ module Runners
3
+ class Selenium
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1,65 @@
1
+ require 'selenium-webdriver'
2
+
3
+ module Jasmine
4
+ module Runners
5
+ class Selenium
6
+ def initialize(formatter, jasmine_server_url, driver, result_batch_size)
7
+ @formatter = formatter
8
+ @jasmine_server_url = jasmine_server_url
9
+ @driver = driver
10
+ @result_batch_size = result_batch_size
11
+ end
12
+
13
+ def run
14
+ driver.navigate.to jasmine_server_url
15
+ ensure_connection_established
16
+ wait_for_suites_to_finish_running
17
+
18
+ formatter.format(get_results)
19
+ formatter.done
20
+ ensure
21
+ driver.quit
22
+ end
23
+
24
+ private
25
+ attr_reader :formatter, :config, :driver, :jasmine_server_url, :result_batch_size
26
+
27
+ def started?
28
+ driver.execute_script "return jsApiReporter && jsApiReporter.started"
29
+ end
30
+
31
+ def finished?
32
+ driver.execute_script "return jsApiReporter && jsApiReporter.finished"
33
+ end
34
+
35
+ def ensure_connection_established
36
+ started = Time.now
37
+ until started? do
38
+ raise "couldn't connect to Jasmine after 60 seconds" if (started + 60 < Time.now)
39
+ sleep 0.1
40
+ end
41
+ end
42
+
43
+ def wait_for_suites_to_finish_running
44
+ puts "Waiting for suite to finish in browser ..."
45
+ until finished? do
46
+ sleep 0.1
47
+ end
48
+ end
49
+
50
+ def get_results
51
+ index = 0
52
+ spec_results = []
53
+
54
+ loop do
55
+ slice = driver.execute_script("return jsApiReporter.specResults(#{index}, #{result_batch_size})")
56
+ spec_results << Jasmine::Result.map_raw_results(slice)
57
+ index += result_batch_size
58
+ break if slice.size < result_batch_size
59
+ end
60
+ spec_results.flatten
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,61 @@
1
+ require 'jasmine'
2
+ require 'jasmine/runners/selenium'
3
+ require 'selenium-webdriver'
4
+
5
+ module JasmineSeleniumRunner
6
+ module ConfigureJasmine
7
+ def self.install_selenium_runner
8
+ Jasmine.configure do |config|
9
+ filepath = File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
10
+ runner_config = YAML::load(ERB.new(File.read(filepath)).result(binding)) if File.exist?(filepath)
11
+ runner_config ||= {}
12
+ config.port = 5555 if runner_config['use_sauce'] #Sauce only proxies certain ports
13
+
14
+ config.runner = lambda { |formatter, jasmine_server_url|
15
+ webdriver = nil
16
+ browser = runner_config['browser'] || 'firefox'
17
+
18
+ if runner_config['use_sauce']
19
+ sauce_config = runner_config['sauce']
20
+
21
+ unless sauce_config['tunnel_identifier']
22
+ require 'sauce/connect'
23
+ Sauce::Connect.connect!
24
+ end
25
+
26
+ username = sauce_config.fetch('username')
27
+ key = sauce_config.fetch('access_key')
28
+ driver_url = "http://#{username}:#{key}@localhost:4445/wd/hub"
29
+
30
+ capabilities = {
31
+ :name => sauce_config['name'],
32
+ :platform => sauce_config['os'],
33
+ :version => sauce_config['browser_version'],
34
+ :build => sauce_config['build'],
35
+ :tags => sauce_config['tags'],
36
+ :browserName => browser,
37
+ 'tunnel-identifier' => sauce_config['tunnel_identifier']
38
+ }
39
+
40
+ webdriver = Selenium::WebDriver.for :remote, :url => driver_url, :desired_capabilities => capabilities
41
+ elsif runner_config['selenium_server']
42
+ webdriver = Selenium::WebDriver.for :remote, :url => runner_config['selenium_server'], :desired_capabilities => browser.to_sym
43
+ else
44
+
45
+ selenium_options = {}
46
+ if browser == 'firefox-firebug'
47
+ require File.join(File.dirname(__FILE__), 'firebug/firebug')
48
+ (profile = Selenium::WebDriver::Firefox::Profile.new)
49
+ profile.enable_firebug
50
+ selenium_options[:profile] = profile
51
+ end
52
+ webdriver = Selenium::WebDriver.for(browser.to_sym, selenium_options)
53
+ end
54
+
55
+ Jasmine::Runners::Selenium.new(formatter, jasmine_server_url, webdriver, runner_config['batch_config_size'] || 50)
56
+ }
57
+ end
58
+ end
59
+ end
60
+ end
61
+
@@ -0,0 +1,30 @@
1
+ Software License Agreement (BSD License)
2
+
3
+ Copyright (c) 2007, Parakey Inc.
4
+ All rights reserved.
5
+
6
+ Redistribution and use of this software in source and binary forms, with or without modification,
7
+ are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above
10
+ copyright notice, this list of conditions and the
11
+ following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above
14
+ copyright notice, this list of conditions and the
15
+ following disclaimer in the documentation and/or other
16
+ materials provided with the distribution.
17
+
18
+ * Neither the name of Parakey Inc. nor the names of its
19
+ contributors may be used to endorse or promote products
20
+ derived from this software without specific prior
21
+ written permission of Parakey Inc.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
24
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
25
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,26 @@
1
+ require 'selenium/webdriver'
2
+
3
+ class Selenium::WebDriver::Firefox::Profile
4
+ def self.firebug_version
5
+ '1.6.2'
6
+ end
7
+
8
+ def enable_firebug(version = nil)
9
+ version ||= Selenium::WebDriver::Firefox::Profile.firebug_version
10
+ add_extension(File.expand_path("../firebug-#{version}.xpi", __FILE__))
11
+
12
+ # Prevent "Welcome!" tab
13
+ self["extensions.firebug.currentVersion"] = "999"
14
+
15
+ # Enable for all sites.
16
+ self["extensions.firebug.allPagesActivation"] = "on"
17
+
18
+ # Enable all features.
19
+ ['console', 'net', 'script'].each do |feature|
20
+ self["extensions.firebug.#{feature}.enableSites"] = true
21
+ end
22
+
23
+ # Open by default.
24
+ self["extensions.firebug.previousPlacement"] = 1
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails/railtie'
2
+
3
+ module JasmineSeleniumRunner
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load 'jasmine_selenium_runner/tasks/jasmine_selenium_runner.rake'
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,8 @@
1
+ namespace :jasmine_selenium_runner do
2
+ task :setup do
3
+ require File.join('jasmine_selenium_runner', 'configure_jasmine')
4
+ JasmineSeleniumRunner::ConfigureJasmine.install_selenium_runner
5
+ end
6
+ end
7
+
8
+ task 'jasmine:require' => ['jasmine_selenium_runner:setup']
@@ -0,0 +1,16 @@
1
+ def safe_gem_check(gem_name, version_string)
2
+ if Gem::Specification.respond_to?(:find_by_name)
3
+ Gem::Specification.find_by_name(gem_name, version_string)
4
+ elsif Gem.respond_to?(:available?)
5
+ Gem.available?(gem_name, version_string)
6
+ end
7
+ rescue Gem::LoadError
8
+ false
9
+ end
10
+
11
+ if safe_gem_check('rails', '>= 3')
12
+ require File.join('jasmine_selenium_runner', 'railtie')
13
+ else
14
+ require File.join('jasmine_selenium_runner', 'configure_jasmine.rb')
15
+ JasmineSeleniumRunner::ConfigureJasmine.install_selenium_runner
16
+ end
@@ -0,0 +1,5 @@
1
+ describe("browser-specific spec that proves we're running in a browser", function() {
2
+ it("should be in firefox", function() {
3
+ expect(navigator.userAgent).toMatch(/Firefox/)
4
+ });
5
+ });
@@ -0,0 +1,5 @@
1
+ describe("browser-specific spec that proves we're running in a browser", function() {
2
+ it("should be in IE", function() {
3
+ expect(navigator.userAgent).toMatch(/MSIE/)
4
+ });
5
+ });
@@ -0,0 +1,52 @@
1
+ require 'rspec'
2
+ require 'yaml'
3
+ require 'selenium-webdriver'
4
+ require 'jasmine_selenium_runner/configure_jasmine'
5
+
6
+ describe "Configuring jasmine" do
7
+
8
+ class FakeConfig
9
+ attr_accessor :port, :runner
10
+ end
11
+
12
+ def configure
13
+ Dir.stub(:pwd).and_return(working_dir)
14
+ Jasmine.stub(:configure).and_yield(fake_config)
15
+ JasmineSeleniumRunner::ConfigureJasmine.install_selenium_runner
16
+ end
17
+
18
+ def stub_config_file(config_obj)
19
+ config_path = File.join(working_dir, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml')
20
+ File.stub(:exist?).with(config_path).and_return(true)
21
+ File.stub(:read).with(config_path).and_return(YAML.dump(config_obj))
22
+ end
23
+
24
+ let(:working_dir) { 'hi' }
25
+ let(:fake_config) { FakeConfig.new }
26
+
27
+ context "when a custom selenium server is specified" do
28
+ before do
29
+ stub_config_file 'selenium_server' => 'http://example.com/selenium/stuff'
30
+ configure
31
+ end
32
+
33
+ it "make a webdriver pointing to the custom server" do
34
+ Selenium::WebDriver.should_receive(:for).with(:remote, hash_including(url: 'http://example.com/selenium/stuff'))
35
+ fake_config.runner.call(nil, nil)
36
+ end
37
+ end
38
+
39
+ context "when the user wants firebug installed" do
40
+ before do
41
+ stub_config_file 'browser' => 'firefox-firebug'
42
+ configure
43
+ end
44
+
45
+ it "should create a firebug profile and pass that to WebDriver" do
46
+ profile = double(:profile, enable_firebug: nil)
47
+ Selenium::WebDriver::Firefox::Profile.stub(:new).and_return(profile)
48
+ Selenium::WebDriver.should_receive(:for).with('firefox-firebug'.to_sym, {profile: profile})
49
+ fake_config.runner.call(nil, nil)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+ require 'tmpdir'
3
+ require 'jasmine'
4
+ require 'json'
5
+ require 'net/http'
6
+
7
+ describe Jasmine::Runners::Selenium do
8
+ let(:file_helper) { FileHelper.new }
9
+ it "permits rake jasmine:ci task to be run using Selenium" do
10
+ in_temp_dir do |dir, project_root|
11
+ File.open(File.join(dir, 'Gemfile'), 'w') do |file|
12
+ file.write <<-GEMFILE
13
+ source 'https://rubygems.org'
14
+ gem 'jasmine_selenium_runner', :path => '#{project_root}'
15
+ gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git'
16
+ GEMFILE
17
+ end
18
+ Bundler.with_clean_env do
19
+ `bundle`
20
+ `bundle exec jasmine init`
21
+ `bundle exec jasmine examples`
22
+ FileUtils.cp(File.join(project_root, 'spec', 'fixtures', 'is_in_firefox_spec.js'), File.join(dir, 'spec', 'javascripts'))
23
+ ci_output = `bundle exec rake -E "require 'jasmine_selenium_runner'" --trace jasmine:ci`
24
+ ci_output.should =~ /[1-9][0-9]* specs, 0 failures/
25
+ end
26
+ end
27
+ end
28
+
29
+ it "permits rake jasmine:ci task to be run using Sauce", :sauce => true do
30
+ in_temp_dir do |dir, project_root|
31
+ File.open(File.join(dir, 'Gemfile'), 'w') do |file|
32
+ file.write <<-GEMFILE
33
+ source 'https://rubygems.org'
34
+ gem 'jasmine_selenium_runner', :path => '#{project_root}'
35
+ gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git'
36
+ GEMFILE
37
+ end
38
+ Bundler.with_clean_env do
39
+ `bundle`
40
+ `bundle exec jasmine init`
41
+ `bundle exec jasmine examples`
42
+ File.open(File.join(dir, 'spec', 'javascripts', 'support', 'jasmine_selenium_runner.yml'), 'w') do |file|
43
+ file.write <<-YAML
44
+ ---
45
+ use_sauce: true
46
+ browser: "internet explorer"
47
+ result_batch_size: 25
48
+ sauce:
49
+ name: "jasmine_selenium_runner <%= Time.now.to_s %>"
50
+ username: #{ENV['SAUCE_USERNAME']}
51
+ access_key: #{ENV['SAUCE_ACCESS_KEY']}
52
+ build: #{ENV['TRAVIS_BUILD_NUMBER'] || 'Ran locally'}
53
+ tags:
54
+ - #{ENV['TRAVIS_RUBY_VERSION'] || RUBY_VERSION}
55
+ - CI
56
+ tunnel_identifier: #{ENV['TRAVIS_JOB_NUMBER'] ? %Q("#{ENV['TRAVIS_JOB_NUMBER']}") : nil}
57
+ os: "Windows 8"
58
+ browser_version: 10
59
+ YAML
60
+ end
61
+
62
+ FileUtils.cp(File.join(project_root, 'spec', 'fixtures', 'is_in_ie_spec.js'), File.join(dir, 'spec', 'javascripts'))
63
+
64
+ test_start_time = Time.now.to_i
65
+ uri = URI.parse "https://saucelabs.com/rest/v1/#{ENV['SAUCE_USERNAME']}/jobs?from=#{test_start_time}"
66
+ job_list_request = Net::HTTP::Get.new(uri)
67
+ job_list_request.basic_auth(ENV['SAUCE_USERNAME'], ENV['SAUCE_ACCESS_KEY'])
68
+ before = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
69
+ http.request(job_list_request)
70
+ end
71
+ JSON.parse(before.body).should == []
72
+ ci_output = %x{bundle exec rake -E "require 'jasmine_selenium_runner'" --trace jasmine:ci}
73
+ ci_output.should =~ (/[1-9][0-9]* specs, 0 failures/)
74
+ after = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
75
+ http.request(job_list_request)
76
+ end
77
+ JSON.parse(after.body).should_not be_empty
78
+ end
79
+ end
80
+ end
81
+
82
+ def bundle_install
83
+ tries_remaining = 3
84
+ while tries_remaining > 0
85
+ puts `NOKOGIRI_USE_SYSTEM_LIBRARIES=true bundle install --path vendor;`
86
+ if $?.success?
87
+ tries_remaining = 0
88
+ else
89
+ tries_remaining -= 1
90
+ puts "\n\nBundle failed, trying #{tries_remaining} more times\n\n"
91
+ end
92
+ end
93
+ end
94
+
95
+ it "works with the rails asset pipeline" do
96
+ in_temp_dir do |dir, project_root|
97
+ `rails new rails-test`
98
+ Dir.chdir File.join(dir, 'rails-test')
99
+ File.open('Gemfile', 'a') { |f|
100
+ f.puts "gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git'"
101
+ f.puts "gem 'jasmine_selenium_runner', :path => '#{project_root}'"
102
+ }
103
+
104
+ Bundler.with_clean_env do
105
+ bundle_install
106
+ `bundle exec rails g jasmine:install`
107
+ `bundle exec rails g jasmine:examples`
108
+ FileUtils.cp(File.join(project_root, 'spec', 'fixtures', 'is_in_firefox_spec.js'), File.join(dir, 'rails-test', 'spec', 'javascripts'))
109
+ output = `bundle exec rake jasmine:ci`
110
+ output.should =~ /[1-9]\d* specs, 0 failures/
111
+ end
112
+ end
113
+ end
114
+ end
115
+
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'jasmine_selenium_runner'
3
+
4
+ RSpec.configure do |config|
5
+ config.before(:each, :sauce => true) do
6
+ unless ENV["SAUCE_USERNAME"] && ENV["SAUCE_ACCESS_KEY"]
7
+ pending "skipping sauce tests because SAUCE_USERNAME and SAUCE_ACCESS_KEY aren't set"
8
+ end
9
+ end
10
+ end
11
+
12
+ def in_temp_dir
13
+ project_root = File.expand_path(File.join('..', '..'), __FILE__)
14
+ Dir.mktmpdir do |tmp_dir|
15
+ begin
16
+ Dir.chdir tmp_dir
17
+ yield tmp_dir, project_root
18
+ ensure
19
+ Dir.chdir project_root
20
+ end
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jasmine_selenium_runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rajan Agaskar
8
+ - Gregg Van Hove
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rails
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: jasmine
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 2.0.0.alpha
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 2.0.0.alpha
84
+ - !ruby/object:Gem::Dependency
85
+ name: selenium-webdriver
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '2.35'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '2.35'
98
+ - !ruby/object:Gem::Dependency
99
+ name: sauce-connect
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ description: Run your jasmine tests in a real live browser!
113
+ email:
114
+ - rajan@pivotallabs.com
115
+ - gvanhove@pivotallabs.com
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - .gitignore
121
+ - .rspec
122
+ - .travis.yml
123
+ - Gemfile
124
+ - LICENSE
125
+ - README.md
126
+ - Rakefile
127
+ - jasmine-selenium-runner.gemspec
128
+ - lib/jasmine/runners/selenium.rb
129
+ - lib/jasmine/runners/selenium/version.rb
130
+ - lib/jasmine_selenium_runner.rb
131
+ - lib/jasmine_selenium_runner/configure_jasmine.rb
132
+ - lib/jasmine_selenium_runner/firebug/firebug-1.6.2.xpi
133
+ - lib/jasmine_selenium_runner/firebug/firebug-license.txt
134
+ - lib/jasmine_selenium_runner/firebug/firebug.rb
135
+ - lib/jasmine_selenium_runner/railtie.rb
136
+ - lib/jasmine_selenium_runner/tasks/jasmine_selenium_runner.rake
137
+ - spec/fixtures/is_in_firefox_spec.js
138
+ - spec/fixtures/is_in_ie_spec.js
139
+ - spec/jasmine_selenium_runner/configure_jasmine_spec.rb
140
+ - spec/selenium_runner_integration_spec.rb
141
+ - spec/spec_helper.rb
142
+ homepage: http://pivotal.github.com/jasmine/
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.0.5
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Run your jasmine tests in a real live browser!
166
+ test_files:
167
+ - spec/fixtures/is_in_firefox_spec.js
168
+ - spec/fixtures/is_in_ie_spec.js
169
+ - spec/jasmine_selenium_runner/configure_jasmine_spec.rb
170
+ - spec/selenium_runner_integration_spec.rb
171
+ - spec/spec_helper.rb