jasmine-multi_json 1.3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.travis.yml +58 -0
- data/Gemfile +8 -0
- data/HOW_TO_TEST.markdown +9 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +77 -0
- data/RELEASE.markdown +22 -0
- data/RELEASE_NOTES.markdown +6 -0
- data/Rakefile +62 -0
- data/generators/jasmine/jasmine_generator.rb +24 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
- data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
- data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +74 -0
- data/jasmine.gemspec +74 -0
- data/lib/generators/jasmine/examples/USAGE +11 -0
- data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
- data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Song.js +7 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
- data/lib/generators/jasmine/install/USAGE +11 -0
- data/lib/generators/jasmine/install/install_generator.rb +18 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +76 -0
- data/lib/jasmine.rb +31 -0
- data/lib/jasmine/application.rb +21 -0
- data/lib/jasmine/asset_expander.rb +19 -0
- data/lib/jasmine/asset_pipeline_mapper.rb +16 -0
- data/lib/jasmine/asset_pipeline_utility.rb +19 -0
- data/lib/jasmine/base.rb +54 -0
- data/lib/jasmine/command_line_tool.rb +70 -0
- data/lib/jasmine/config.rb +85 -0
- data/lib/jasmine/configuration.rb +83 -0
- data/lib/jasmine/core_configuration.rb +28 -0
- data/lib/jasmine/dependencies.rb +59 -0
- data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
- data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
- data/lib/jasmine/firebug/firebug-license.txt +30 -0
- data/lib/jasmine/firebug/firebug.rb +30 -0
- data/lib/jasmine/javascripts/boot.js +28 -0
- data/lib/jasmine/page.rb +11 -0
- data/lib/jasmine/path_expander.rb +18 -0
- data/lib/jasmine/path_mapper.rb +29 -0
- data/lib/jasmine/railtie.rb +21 -0
- data/lib/jasmine/results.rb +19 -0
- data/lib/jasmine/results_processor.rb +38 -0
- data/lib/jasmine/rspec_formatter.rb +92 -0
- data/lib/jasmine/run.html.erb +18 -0
- data/lib/jasmine/run_specs.rb +36 -0
- data/lib/jasmine/runners/http.rb +71 -0
- data/lib/jasmine/selenium_driver.rb +41 -0
- data/lib/jasmine/server.rb +20 -0
- data/lib/jasmine/tasks/jasmine.rake +55 -0
- data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
- data/lib/jasmine/version.rb +3 -0
- data/lib/jasmine/yaml_config_parser.rb +54 -0
- data/lib/rack/jasmine/cache_control.rb +20 -0
- data/lib/rack/jasmine/focused_suite.rb +17 -0
- data/lib/rack/jasmine/runner.rb +27 -0
- data/spec/application_integration_spec.rb +15 -0
- data/spec/application_spec.rb +44 -0
- data/spec/asset_expander_spec.rb +42 -0
- data/spec/asset_pipeline_mapper_spec.rb +19 -0
- data/spec/base_spec.rb +14 -0
- data/spec/configuration_spec.rb +163 -0
- data/spec/dependencies_spec.rb +315 -0
- data/spec/fixture/Rakefile +4 -0
- data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
- data/spec/jasmine_command_line_tool_spec.rb +29 -0
- data/spec/jasmine_pojs_spec.rb +47 -0
- data/spec/jasmine_rails2_spec.rb +89 -0
- data/spec/jasmine_rails3_spec.rb +69 -0
- data/spec/jasmine_self_test_spec.rb +29 -0
- data/spec/page_spec.rb +23 -0
- data/spec/path_expander_spec.rb +96 -0
- data/spec/path_mapper_spec.rb +33 -0
- data/spec/rack/jasmine/runner_spec.rb +25 -0
- data/spec/results_processor_spec.rb +3 -0
- data/spec/results_spec.rb +27 -0
- data/spec/rspec_formatter_spec.rb +88 -0
- data/spec/server_spec.rb +48 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/yaml_config_parser_spec.rb +182 -0
- metadata +310 -0
Binary file
|
Binary file
|
@@ -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,30 @@
|
|
1
|
+
require 'selenium/webdriver'
|
2
|
+
|
3
|
+
class Selenium::WebDriver::Firefox::Profile
|
4
|
+
def self.firebug_version
|
5
|
+
@firebug_version ||= '1.6.2'
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.firebug_version=(version)
|
9
|
+
@firebug_version = version
|
10
|
+
end
|
11
|
+
|
12
|
+
def enable_firebug(version = nil)
|
13
|
+
version ||= Selenium::WebDriver::Firefox::Profile.firebug_version
|
14
|
+
add_extension(File.expand_path("../firebug-#{version}.xpi", __FILE__))
|
15
|
+
|
16
|
+
# Prevent "Welcome!" tab
|
17
|
+
self["extensions.firebug.currentVersion"] = "999"
|
18
|
+
|
19
|
+
# Enable for all sites.
|
20
|
+
self["extensions.firebug.allPagesActivation"] = "on"
|
21
|
+
|
22
|
+
# Enable all features.
|
23
|
+
['console', 'net', 'script'].each do |feature|
|
24
|
+
self["extensions.firebug.#{feature}.enableSites"] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Open by default.
|
28
|
+
self["extensions.firebug.previousPlacement"] = 1
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
var jsApiReporter;
|
2
|
+
(function() {
|
3
|
+
var jasmineEnv = jasmine.getEnv();
|
4
|
+
|
5
|
+
jsApiReporter = new jasmine.JsApiReporter();
|
6
|
+
var htmlReporter = new jasmine.HtmlReporter();
|
7
|
+
|
8
|
+
jasmineEnv.addReporter(jsApiReporter);
|
9
|
+
jasmineEnv.addReporter(htmlReporter);
|
10
|
+
|
11
|
+
jasmineEnv.specFilter = function(spec) {
|
12
|
+
return htmlReporter.specFilter(spec);
|
13
|
+
};
|
14
|
+
|
15
|
+
var currentWindowOnload = window.onload;
|
16
|
+
|
17
|
+
window.onload = function() {
|
18
|
+
if (currentWindowOnload) {
|
19
|
+
currentWindowOnload();
|
20
|
+
}
|
21
|
+
execJasmine();
|
22
|
+
};
|
23
|
+
|
24
|
+
function execJasmine() {
|
25
|
+
jasmineEnv.execute();
|
26
|
+
}
|
27
|
+
|
28
|
+
})();
|
data/lib/jasmine/page.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class PathExpander
|
3
|
+
|
4
|
+
def self.expand(base_directory, patterns, globber = Dir.method(:glob))
|
5
|
+
negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
|
6
|
+
chosen, negated = [positive, negative].collect do |patterns|
|
7
|
+
patterns.map do |path|
|
8
|
+
files = globber.call(File.join(base_directory, path.gsub(/^!/, '')))
|
9
|
+
if files.empty? && !(path =~ /\*|^\!/)
|
10
|
+
files = [File.join(base_directory, path)]
|
11
|
+
end
|
12
|
+
files
|
13
|
+
end.flatten.uniq
|
14
|
+
end
|
15
|
+
chosen - negated
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class PathMapper
|
3
|
+
def initialize(config)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def map_src_paths(paths)
|
8
|
+
map(paths, @config.src_dir, @config.src_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def map_spec_paths(paths)
|
12
|
+
map(paths, @config.spec_dir, @config.spec_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def map_boot_paths(paths)
|
16
|
+
map(paths, @config.boot_dir, @config.boot_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def map_jasmine_paths(paths)
|
20
|
+
map(paths, @config.jasmine_dir, @config.jasmine_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def map(paths, remove_path, add_path)
|
25
|
+
paths.map { |path| File.join(add_path, (path.gsub(remove_path, ''))) }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails/railtie"
|
2
|
+
module Jasmine
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
|
5
|
+
config.before_configuration do
|
6
|
+
old_jasmine_rakefile = ::Rails.root.join('lib', 'tasks', 'jasmine.rake')
|
7
|
+
if old_jasmine_rakefile.exist? && !ENV["USE_JASMINE_RAKE"]
|
8
|
+
puts %Q{
|
9
|
+
You no longer need to have jasmine.rake in your project, as it is now automatically loaded
|
10
|
+
from the Jasmine gem. To silence this warning, set "USE_JASMINE_RAKE=true" in your environment
|
11
|
+
or remove jasmine.rake.
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
rake_tasks do
|
17
|
+
load "jasmine/tasks/jasmine.rake"
|
18
|
+
load "jasmine/tasks/jasmine_rails3.rake"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class Results
|
3
|
+
|
4
|
+
attr_reader :suites
|
5
|
+
def initialize(result_hash, suite_hash, example_locations)
|
6
|
+
@suites = suite_hash
|
7
|
+
@results = result_hash
|
8
|
+
@example_locations = example_locations
|
9
|
+
end
|
10
|
+
|
11
|
+
def for_spec_id(id)
|
12
|
+
@results[id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def example_location_for(spec_description)
|
16
|
+
@example_locations[spec_description]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class ResultsProcessor
|
3
|
+
|
4
|
+
def initialize(config)
|
5
|
+
@config = config
|
6
|
+
end
|
7
|
+
|
8
|
+
def process(results_hash, suites_hash)
|
9
|
+
return Jasmine::Results.new(results_hash, suites_hash, example_locations)
|
10
|
+
end
|
11
|
+
|
12
|
+
def example_locations
|
13
|
+
# example_locations = {}
|
14
|
+
# example_name_parts = []
|
15
|
+
# previous_indent_level = 0
|
16
|
+
# @config.spec_files_full_paths.each do |filename|
|
17
|
+
# line_number = 1
|
18
|
+
# File.open(filename, "r") do |file|
|
19
|
+
# file.readlines.each do |line|
|
20
|
+
# match = /^(\s*)(describe|it)\s*\(\s*["'](.*)["']\s*,\s*function/.match(line)
|
21
|
+
# if (match)
|
22
|
+
# indent_level = match[1].length / 2
|
23
|
+
# example_name = match[3]
|
24
|
+
# example_name_parts[indent_level] = example_name
|
25
|
+
|
26
|
+
# full_example_name = example_name_parts.slice(0, indent_level + 1).join(" ")
|
27
|
+
# example_locations[full_example_name] = "#{filename}:#{line_number}: in `it'"
|
28
|
+
# end
|
29
|
+
# line_number += 1
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
# example_locations
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'enumerator'
|
2
|
+
|
3
|
+
module Jasmine
|
4
|
+
class RspecFormatter
|
5
|
+
|
6
|
+
def format_results(results)
|
7
|
+
@results = results
|
8
|
+
declare_suites(@results.suites)
|
9
|
+
end
|
10
|
+
|
11
|
+
def declare_suites(suites)
|
12
|
+
suites.each do |suite|
|
13
|
+
#empty block for rspec 1
|
14
|
+
group = example_group(suite["name"]) {}
|
15
|
+
process_children(group, suite["children"])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_children(parent, children)
|
20
|
+
children.each do |suite_or_spec|
|
21
|
+
type = suite_or_spec["type"]
|
22
|
+
if type == "suite"
|
23
|
+
process_children(parent.describe(suite_or_spec["name"]), suite_or_spec["children"])
|
24
|
+
elsif type == "spec"
|
25
|
+
declare_spec(parent, suite_or_spec)
|
26
|
+
else
|
27
|
+
raise "unknown type #{type} for #{suite_or_spec.inspect}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def declare_spec(parent, spec)
|
33
|
+
me = self
|
34
|
+
example_name = spec["name"]
|
35
|
+
backtrace = @results.example_location_for(parent.description + " " + example_name)
|
36
|
+
if Jasmine::Dependencies.rspec2?
|
37
|
+
parent.it example_name, {} do
|
38
|
+
me.report_spec(spec["id"])
|
39
|
+
end
|
40
|
+
else
|
41
|
+
parent.it example_name, {}, backtrace do
|
42
|
+
me.report_spec(spec["id"])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def report_spec(spec_id)
|
48
|
+
spec_results = results_for(spec_id)
|
49
|
+
out = ""
|
50
|
+
messages = spec_results['messages'].each do |message|
|
51
|
+
case
|
52
|
+
when message["type"] == "log"
|
53
|
+
puts message["text"]
|
54
|
+
puts "\n"
|
55
|
+
else
|
56
|
+
unless message["message"] =~ /^Passed.$/
|
57
|
+
STDERR << message["message"]
|
58
|
+
STDERR << "\n"
|
59
|
+
|
60
|
+
out << message["message"]
|
61
|
+
out << "\n"
|
62
|
+
end
|
63
|
+
|
64
|
+
if !message["passed"] && message["trace"]["stack"]
|
65
|
+
stack_trace = message["trace"]["stack"].gsub(/<br \/>/, "\n").gsub(/<\/?b>/, " ")
|
66
|
+
STDERR << stack_trace.gsub(/\(.*\)@http:\/\/localhost:[0-9]+\/specs\//, "/spec/")
|
67
|
+
STDERR << "\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
fail out unless spec_results['result'] == 'passed'
|
73
|
+
puts out unless out.empty?
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def example_group(*args, &block)
|
79
|
+
if Jasmine::Dependencies.rspec2?
|
80
|
+
RSpec::Core::ExampleGroup.describe(*args, &block).register
|
81
|
+
else
|
82
|
+
Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def results_for(spec_id)
|
87
|
+
@results.for_spec_id(spec_id.to_s)
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
5
|
+
<title>Jasmine suite</title>
|
6
|
+
<link rel="shortcut icon" type="image/png" href="/__JASMINE_ROOT__/images/jasmine_favicon.png">
|
7
|
+
<% css_files.each do |css_file| %>
|
8
|
+
<link rel="stylesheet" href="<%= css_file %>" type="text/css" media="screen"/>
|
9
|
+
<% end %>
|
10
|
+
<% js_files.each do |js_file| %>
|
11
|
+
<script src="<%= js_file %>" type="text/javascript"></script>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<div id="jasmine_content"></div>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'jasmine'
|
5
|
+
if Jasmine::Dependencies.rspec2?
|
6
|
+
require 'rspec'
|
7
|
+
else
|
8
|
+
require 'spec'
|
9
|
+
end
|
10
|
+
|
11
|
+
jasmine_yml = File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine.yml')
|
12
|
+
if File.exist?(jasmine_yml)
|
13
|
+
end
|
14
|
+
|
15
|
+
Jasmine.load_configuration_from_yaml
|
16
|
+
|
17
|
+
config = Jasmine.config
|
18
|
+
|
19
|
+
server = Jasmine::Server.new(config.port, Jasmine::Application.app(config))
|
20
|
+
driver = Jasmine::SeleniumDriver.new(config.browser, "#{config.host}:#{config.port}/")
|
21
|
+
t = Thread.new do
|
22
|
+
begin
|
23
|
+
server.start
|
24
|
+
rescue ChildProcess::TimeoutError
|
25
|
+
end
|
26
|
+
# # ignore bad exits
|
27
|
+
end
|
28
|
+
t.abort_on_exception = true
|
29
|
+
Jasmine::wait_for_listener(config.port, "jasmine server")
|
30
|
+
puts "jasmine server started."
|
31
|
+
|
32
|
+
results_processor = Jasmine::ResultsProcessor.new(config)
|
33
|
+
results = Jasmine::Runners::HTTP.new(driver, results_processor, config.result_batch_size).run
|
34
|
+
formatter = Jasmine::RspecFormatter.new
|
35
|
+
formatter.format_results(results)
|
36
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Jasmine
|
2
|
+
module Runners
|
3
|
+
class HTTP
|
4
|
+
attr_accessor :suites
|
5
|
+
|
6
|
+
def initialize(client, results_processor, result_batch_size)
|
7
|
+
@client = client
|
8
|
+
@results_processor = results_processor
|
9
|
+
@result_batch_size = result_batch_size
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
@client.connect
|
14
|
+
load_suite_info
|
15
|
+
wait_for_suites_to_finish_running
|
16
|
+
results = @results_processor.process(results_hash, suites)
|
17
|
+
@client.disconnect
|
18
|
+
results
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def load_suite_info
|
24
|
+
started = Time.now
|
25
|
+
while !eval_js('return jsApiReporter && jsApiReporter.started') do
|
26
|
+
raise "couldn't connect to Jasmine after 60 seconds" if (started + 60 < Time.now)
|
27
|
+
sleep 0.1
|
28
|
+
end
|
29
|
+
|
30
|
+
@suites = eval_js("var result = jsApiReporter.suites(); if (window.Prototype && Object.toJSON) { return Object.toJSON(result) } else { return JSON.stringify(result) }")
|
31
|
+
end
|
32
|
+
|
33
|
+
def results_hash
|
34
|
+
spec_results = {}
|
35
|
+
spec_ids.each_slice(@result_batch_size) do |slice|
|
36
|
+
spec_results.merge!(eval_js("var result = jsApiReporter.resultsForSpecs(#{json_generate(slice)}); if (window.Prototype && Object.toJSON) { return Object.toJSON(result) } else { return JSON.stringify(result) }"))
|
37
|
+
end
|
38
|
+
spec_results
|
39
|
+
end
|
40
|
+
|
41
|
+
def spec_ids
|
42
|
+
map_spec_ids = lambda do |suites|
|
43
|
+
suites.map do |suite_or_spec|
|
44
|
+
if suite_or_spec['type'] == 'spec'
|
45
|
+
suite_or_spec['id']
|
46
|
+
else
|
47
|
+
map_spec_ids.call(suite_or_spec['children'])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
map_spec_ids.call(@suites).compact.flatten
|
52
|
+
end
|
53
|
+
|
54
|
+
def wait_for_suites_to_finish_running
|
55
|
+
puts "Waiting for suite to finish in browser ..."
|
56
|
+
while !eval_js('return jsApiReporter.finished') do
|
57
|
+
sleep 0.1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def eval_js(script)
|
62
|
+
@client.eval_js(script)
|
63
|
+
end
|
64
|
+
|
65
|
+
def json_generate(obj)
|
66
|
+
@client.json_generate(obj)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|