diff --git a/.gitignore b/.gitignore
index 9f11b75..4c0b8ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
.idea/
+.svn/
diff --git a/contrib/ruby/jasmine_runner.rb b/contrib/ruby/jasmine_runner.rb
index dee3b71..44f3026 100644
--- a/contrib/ruby/jasmine_runner.rb
+++ b/contrib/ruby/jasmine_runner.rb
@@ -173,21 +173,18 @@ module Jasmine
def eval_js(script)
escaped_script = "'" + script.gsub(/(['\\])/) { '\\' + $1 } + "'"
- begin
- result = @driver.get_eval("window.eval(#{escaped_script})")
- rescue Selenium::CommandError
- result = @driver.get_eval("eval(#{escaped_script}, window)")
- end
+ result = @driver.get_eval(" try { eval(#{escaped_script}, window); } catch(err) { window.eval(#{escaped_script}); }")
JSON.parse("[#{result}]")[0]
end
end
class Runner
- def initialize(selenium_jar_path, spec_files, dir_mappings, jasmine_files = nil)
+ def initialize(selenium_jar_path, spec_files, dir_mappings, jasmine_files = nil, options={})
@selenium_jar_path = selenium_jar_path
@spec_files = spec_files
@dir_mappings = dir_mappings
@jasmine_files = jasmine_files
+ @browser = options[:browser] || 'firefox'
@selenium_pid = nil
@jasmine_server_pid = nil
@@ -195,7 +192,7 @@ module Jasmine
def start
start_servers
- @client = Jasmine::SimpleClient.new("localhost", @selenium_server_port, "*firefox", "http://localhost:#{@jasmine_server_port}/")
+ @client = Jasmine::SimpleClient.new("localhost", @selenium_server_port, "*#{@browser}", "http://localhost:#{@jasmine_server_port}/")
@client.connect
end
diff --git a/contrib/ruby/jasmine_spec_builder.rb b/contrib/ruby/jasmine_spec_builder.rb
index ab3ee11..260c9e2 100644
--- a/contrib/ruby/jasmine_spec_builder.rb
+++ b/contrib/ruby/jasmine_spec_builder.rb
@@ -1,5 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_runner.rb"))
-
+require 'enumerator'
module Jasmine
class SpecBuilder
@@ -8,6 +8,7 @@ module Jasmine
def initialize(spec_files, runner)
@spec_files = spec_files
@runner = runner
+ @spec_ids = []
end
def start
@@ -15,7 +16,7 @@ module Jasmine
@runner.start
load_suite_info
- @spec_results = {}
+ wait_for_suites_to_finish_running
end
def stop
@@ -61,16 +62,23 @@ module Jasmine
end
def results_for(spec_id)
- spec_id = spec_id.to_s
- return @spec_results[spec_id] if @spec_results[spec_id]
+ @spec_results ||= load_results
+ @spec_results[spec_id.to_s]
+ end
- @spec_results[spec_id] = eval_js("JSON.stringify(jsApiReporter.resultsForSpec(#{spec_id}))")
- while @spec_results[spec_id].nil? do
- sleep 0.1
- @spec_results[spec_id] = eval_js("JSON.stringify(jsApiReporter.resultsForSpec(#{spec_id}))")
+ def load_results
+ @spec_results = {}
+ @spec_ids.each_slice(50) do |slice|
+ @spec_results.merge!(eval_js("JSON.stringify(jsApiReporter.resultsForSpecs(#{JSON.generate(slice)}))"))
end
+ @spec_results
+ end
- @spec_results[spec_id]
+ def wait_for_suites_to_finish_running
+ puts "Waiting for suite to finish in browser ..."
+ while !eval_js('jsApiReporter.finished') do
+ sleep 0.1
+ end
end
def declare_suites
@@ -99,7 +107,7 @@ module Jasmine
def declare_spec(parent, spec)
me = self
example_name = spec["name"]
-
+ @spec_ids << spec["id"]
backtrace = @example_locations[parent.description + " " + example_name]
parent.it example_name, {}, backtrace do
me.report_spec(spec["id"])
@@ -124,7 +132,7 @@ module Jasmine
out << "\n"
end
- unless message["passed_"]
+ if !message["passed"] && message["trace"]["stack"]
stack_trace = message["trace"]["stack"].gsub(/
/, "\n").gsub(/<\/?b>/, " ")
STDERR << stack_trace.gsub(/\(.*\)@http:\/\/localhost:[0-9]+\/specs\//, "/spec/")
STDERR << "\n"
@@ -143,4 +151,3 @@ module Jasmine
end
end
end
-
\ No newline at end of file
diff --git a/doc/files.html b/doc/files.html
index f9c2a66..43b9de3 100644
--- a/doc/files.html
+++ b/doc/files.html
@@ -258,7 +258,7 @@ ul.inheritsList