diff --git a/Rakefile b/Rakefile index 4ce8838..2bb0f6e 100644 --- a/Rakefile +++ b/Rakefile @@ -59,7 +59,7 @@ namespace :jasmine do task :build => :lint do puts 'Building Jasmine from source' require 'json' - + sources = jasmine_sources version = version_hash @@ -119,17 +119,26 @@ jasmine.version_= { end namespace :test do - desc "Run continuous integration tests" - task :ci => 'jasmine:build' do - require "spec" - require 'spec/rake/spectask' - Spec::Rake::SpecTask.new(:lambda_ci) do |t| - t.spec_opts = ["--color", "--format", "specdoc"] - t.spec_files = ["spec/jasmine_spec.rb"] - end - Rake::Task[:lambda_ci].invoke - end + desc "Run continuous integration tests using a local Selenium runner" + task :ci => :'ci:local' + namespace :ci do + task :local => 'jasmine:build' do + require "spec" + require 'spec/rake/spectask' + Spec::Rake::SpecTask.new(:lambda_ci) do |t| + t.spec_opts = ["--color", "--format", "specdoc"] + t.spec_files = ["spec/jasmine_spec.rb"] + end + Rake::Task[:lambda_ci].invoke + end + + desc "Run continuous integration tests using Sauce Labs 'Selenium in the Cloud'" + task :saucelabs => 'jasmine:build' do + ENV['SAUCELABS'] = 'true' + Rake::Task['jasmine:test:ci:local'].invoke + end + end end -end \ No newline at end of file +end diff --git a/contrib/ruby/jasmine_runner.rb b/contrib/ruby/jasmine_runner.rb index 5a6b1ef..2388396 100644 --- a/contrib/ruby/jasmine_runner.rb +++ b/contrib/ruby/jasmine_runner.rb @@ -228,46 +228,53 @@ module Jasmine @browser = options[:browser] ? options[:browser].delete(:browser) : 'firefox' @selenium_pid = nil @jasmine_server_pid = nil + @selenium_host = 'localhost' + @jasmine_server_port = Jasmine::find_unused_port + @selenium_server_port = Jasmine::find_unused_port end def start - start_servers - @client = Jasmine::SimpleClient.new("localhost", @selenium_server_port, "*#{@browser}", "http://localhost:#{@jasmine_server_port}/") + start_jasmine_server + start_selenium_server + @client = Jasmine::SimpleClient.new(@selenium_host, @selenium_server_port, "*#{@browser}", "http://localhost:#{@jasmine_server_port}/") @client.connect end def stop @client.disconnect - stop_servers + stop_selenium_server + stop_jasmine_server end - def start_servers - @jasmine_server_port = Jasmine::find_unused_port - @selenium_server_port = Jasmine::find_unused_port - - @selenium_pid = fork do - Process.setpgrp - exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1" - end - puts "selenium started. pid is #{@selenium_pid}" - + def start_jasmine_server @jasmine_server_pid = fork do Process.setpgrp Jasmine::SimpleServer.start(@jasmine_server_port, @spec_files, @dir_mappings, @options) exit! 0 end puts "jasmine server started. pid is #{@jasmine_server_pid}" - - Jasmine::wait_for_listener(@selenium_server_port, "selenium server") Jasmine::wait_for_listener(@jasmine_server_port, "jasmine server") end - def stop_servers - puts "shutting down the servers..." - Jasmine::kill_process_group(@selenium_pid) if @selenium_pid + def start_selenium_server + @selenium_pid = fork do + Process.setpgrp + exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1" + end + puts "selenium started. pid is #{@selenium_pid}" + Jasmine::wait_for_listener(@selenium_server_port, "selenium server") + end + + def stop_jasmine_server + puts "shutting down Jasmine server..." Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid end + def stop_selenium_server + puts "shutting down Selenium server..." + Jasmine::kill_process_group(@selenium_pid) if @selenium_pid + end + def run begin start @@ -284,6 +291,40 @@ module Jasmine end end + class SauceLabsRunner < Runner + def initialize(spec_files, dir_mappings, options={}) + @spec_files = spec_files + @dir_mappings = dir_mappings + @options = options + + @browser = options[:browser] ? options[:browser].delete(:browser) : 'firefox' + @jasmine_server_pid = nil + @jasmine_server_port = Jasmine::find_unused_port + @saucelabs_config = SeleniumConfig.new(options[:saucelabs_config], options[:saucelabs_config_file], @jasmine_server_port) + end + + def start_selenium_server + @sauce_tunnel = SauceTunnel.new(@saucelabs_config) + end + + def start + start_jasmine_server + start_selenium_server + @client = Jasmine::SimpleClient.new(@saucelabs_config['selenium_server_address'], + 4444, + @saucelabs_config['selenium_browser_key'], + "http://#{@saucelabs_config['application_address']}") + @client.connect + end + + def stop + @client.disconnect + @sauce_tunnel.shutdown + stop_jasmine_server + end + + end + def self.files(f) result = f result = result.call if result.respond_to?(:call) diff --git a/doc/files.html b/doc/files.html index bce9c40..dfdecfe 100644 --- a/doc/files.html +++ b/doc/files.html @@ -454,7 +454,7 @@ ul.inheritsList