snapdragon 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/.ruby-version +1 -1
- data/ChangeLog.markdown +7 -2
- data/lib/jasmine/MIT.LICENSE +20 -0
- data/lib/jasmine/boot.js +181 -0
- data/lib/jasmine/console.js +160 -0
- data/lib/jasmine/jasmine-html.js +359 -0
- data/lib/jasmine/jasmine.css +55 -0
- data/lib/jasmine/jasmine.js +2402 -0
- data/lib/jasmine/jasmine_favicon.png +0 -0
- data/lib/jasmine_v1/MIT.LICENSE +20 -0
- data/lib/{jasmine/lib/jasmine-core → jasmine_v1}/jasmine-html.js +0 -0
- data/lib/{jasmine/lib/jasmine-core → jasmine_v1}/jasmine.css +0 -0
- data/lib/{jasmine/lib/jasmine-core → jasmine_v1}/jasmine.js +0 -0
- data/lib/snapdragon/command_line_parser.rb +7 -3
- data/lib/snapdragon/resources/SnapdragonConsoleReporter.js +129 -128
- data/lib/snapdragon/resources/SnapdragonConsoleReporter_v1.js +162 -0
- data/lib/snapdragon/resources/SnapdragonJUnitReporter.js +142 -131
- data/lib/snapdragon/resources/SnapdragonJUnitReporter_v1.js +158 -0
- data/lib/snapdragon/suite.rb +4 -0
- data/lib/snapdragon/version.rb +1 -1
- data/lib/snapdragon/views/run.erb +21 -44
- data/lib/snapdragon/views/run_v1.erb +60 -0
- data/lib/snapdragon/web_application.rb +11 -3
- data/snapdragon.gemspec +7 -7
- data/spec/lib/snapdragon/cli_application_spec.rb +20 -19
- data/spec/lib/snapdragon/command_line_parser_spec.rb +44 -20
- data/spec/lib/snapdragon/path_spec.rb +21 -20
- data/spec/lib/snapdragon/spec_directory_spec.rb +2 -1
- data/spec/lib/snapdragon/spec_file_spec.rb +2 -1
- data/spec/lib/snapdragon/suite_spec.rb +54 -44
- data/spec/spec_helper.rb +7 -0
- metadata +51 -48
- data/lib/jasmine/lib/jasmine-core/example/SpecRunner.html +0 -54
- data/lib/jasmine/lib/jasmine-core/example/spec/PlayerSpec.js +0 -58
- data/lib/jasmine/lib/jasmine-core/example/spec/SpecHelper.js +0 -9
- data/lib/jasmine/lib/jasmine-core/example/src/Player.js +0 -22
- data/lib/jasmine/lib/jasmine-core/example/src/Song.js +0 -7
- data/lib/jasmine/lib/jasmine-core/json2.js +0 -478
- data/lib/jasmine/lib/jasmine-core/version.rb +0 -6
- data/lib/snapdragon/resources/.gitkeep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8cdfdd0846cd96cc185b3b062fcec610a13c3f6
|
4
|
+
data.tar.gz: 6ded32f39a330645028d531a770e4c4f621458fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82ccdfda0be07b0313dd44892c785ecc7f092e1b4ded6c2928ba5e4b0a367b4cd962cbb534ed34342a07fd9daa0988377f6d6a3c4a92ab4cc1d8f913d4e6edb5
|
7
|
+
data.tar.gz: 15b8a47d560f1115b3fb5a3a7fef70ef87da0f31183e2000237c30ae35a2b9cf2a690a749baef52d81f27e75cd90d22c636a38dbdb378afeb06b36820b0876cb
|
data/.gitmodules
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.1.0
|
data/ChangeLog.markdown
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# ChangeLog
|
2
2
|
|
3
3
|
The following are lists of the notable changes included with each release.
|
4
|
-
This is
|
4
|
+
This is intended to help keep people informed about notable changes between
|
5
5
|
versions as well as provide a rough history.
|
6
6
|
|
7
7
|
#### Next Release
|
8
8
|
|
9
|
+
#### v2.0.0
|
10
|
+
|
11
|
+
* switched to Jasmine 2 instead of Jasmine 1.3.1
|
12
|
+
* added -J1, --jasminev1 option to allow people to still use Jasmine v1.3.1
|
13
|
+
|
9
14
|
#### v1.0.0
|
10
15
|
|
11
16
|
This release doesn't include any new changes. It is simply here to signify
|
@@ -16,7 +21,7 @@ shouldn't be changing in ways that would break existing functionality.
|
|
16
21
|
|
17
22
|
* added -P, --pattern options to over the test file search pattern as well as
|
18
23
|
a default test file search pattern when not given an explicit file or
|
19
|
-
directory path.
|
24
|
+
directory path.
|
20
25
|
|
21
26
|
#### v0.1.12
|
22
27
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2011 Pivotal Labs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/jasmine/boot.js
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
/**
|
2
|
+
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
|
3
|
+
|
4
|
+
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
|
5
|
+
|
6
|
+
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
|
7
|
+
|
8
|
+
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
|
9
|
+
*/
|
10
|
+
|
11
|
+
(function() {
|
12
|
+
|
13
|
+
/**
|
14
|
+
* ## Require & Instantiate
|
15
|
+
*
|
16
|
+
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
17
|
+
*/
|
18
|
+
window.jasmine = jasmineRequire.core(jasmineRequire);
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
22
|
+
*/
|
23
|
+
jasmineRequire.html(jasmine);
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Create the Jasmine environment. This is used to run all specs in a project.
|
27
|
+
*/
|
28
|
+
var env = jasmine.getEnv();
|
29
|
+
|
30
|
+
/**
|
31
|
+
* ## The Global Interface
|
32
|
+
*
|
33
|
+
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
34
|
+
*/
|
35
|
+
var jasmineInterface = {
|
36
|
+
describe: function(description, specDefinitions) {
|
37
|
+
return env.describe(description, specDefinitions);
|
38
|
+
},
|
39
|
+
|
40
|
+
xdescribe: function(description, specDefinitions) {
|
41
|
+
return env.xdescribe(description, specDefinitions);
|
42
|
+
},
|
43
|
+
|
44
|
+
it: function(desc, func) {
|
45
|
+
return env.it(desc, func);
|
46
|
+
},
|
47
|
+
|
48
|
+
xit: function(desc, func) {
|
49
|
+
return env.xit(desc, func);
|
50
|
+
},
|
51
|
+
|
52
|
+
beforeEach: function(beforeEachFunction) {
|
53
|
+
return env.beforeEach(beforeEachFunction);
|
54
|
+
},
|
55
|
+
|
56
|
+
afterEach: function(afterEachFunction) {
|
57
|
+
return env.afterEach(afterEachFunction);
|
58
|
+
},
|
59
|
+
|
60
|
+
expect: function(actual) {
|
61
|
+
return env.expect(actual);
|
62
|
+
},
|
63
|
+
|
64
|
+
pending: function() {
|
65
|
+
return env.pending();
|
66
|
+
},
|
67
|
+
|
68
|
+
spyOn: function(obj, methodName) {
|
69
|
+
return env.spyOn(obj, methodName);
|
70
|
+
},
|
71
|
+
|
72
|
+
jsApiReporter: new jasmine.JsApiReporter({
|
73
|
+
timer: new jasmine.Timer()
|
74
|
+
})
|
75
|
+
};
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
79
|
+
*/
|
80
|
+
if (typeof window == "undefined" && typeof exports == "object") {
|
81
|
+
extend(exports, jasmineInterface);
|
82
|
+
} else {
|
83
|
+
extend(window, jasmineInterface);
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Expose the interface for adding custom equality testers.
|
88
|
+
*/
|
89
|
+
jasmine.addCustomEqualityTester = function(tester) {
|
90
|
+
env.addCustomEqualityTester(tester);
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Expose the interface for adding custom expectation matchers
|
95
|
+
*/
|
96
|
+
jasmine.addMatchers = function(matchers) {
|
97
|
+
return env.addMatchers(matchers);
|
98
|
+
};
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Expose the mock interface for the JavaScript timeout functions
|
102
|
+
*/
|
103
|
+
jasmine.clock = function() {
|
104
|
+
return env.clock;
|
105
|
+
};
|
106
|
+
|
107
|
+
/**
|
108
|
+
* ## Runner Parameters
|
109
|
+
*
|
110
|
+
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
111
|
+
*/
|
112
|
+
|
113
|
+
var queryString = new jasmine.QueryString({
|
114
|
+
getWindowLocation: function() { return window.location; }
|
115
|
+
});
|
116
|
+
|
117
|
+
var catchingExceptions = queryString.getParam("catch");
|
118
|
+
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
119
|
+
|
120
|
+
/**
|
121
|
+
* ## Reporters
|
122
|
+
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
123
|
+
*/
|
124
|
+
var htmlReporter = new jasmine.HtmlReporter({
|
125
|
+
env: env,
|
126
|
+
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
127
|
+
getContainer: function() { return document.body; },
|
128
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
129
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
130
|
+
timer: new jasmine.Timer()
|
131
|
+
});
|
132
|
+
|
133
|
+
/**
|
134
|
+
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
135
|
+
*/
|
136
|
+
env.addReporter(jasmineInterface.jsApiReporter);
|
137
|
+
env.addReporter(htmlReporter);
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
141
|
+
*/
|
142
|
+
var specFilter = new jasmine.HtmlSpecFilter({
|
143
|
+
filterString: function() { return queryString.getParam("spec"); }
|
144
|
+
});
|
145
|
+
|
146
|
+
env.specFilter = function(spec) {
|
147
|
+
return specFilter.matches(spec.getFullName());
|
148
|
+
};
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
152
|
+
*/
|
153
|
+
window.setTimeout = window.setTimeout;
|
154
|
+
window.setInterval = window.setInterval;
|
155
|
+
window.clearTimeout = window.clearTimeout;
|
156
|
+
window.clearInterval = window.clearInterval;
|
157
|
+
|
158
|
+
/**
|
159
|
+
* ## Execution
|
160
|
+
*
|
161
|
+
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
162
|
+
*/
|
163
|
+
var currentWindowOnload = window.onload;
|
164
|
+
|
165
|
+
window.onload = function() {
|
166
|
+
if (currentWindowOnload) {
|
167
|
+
currentWindowOnload();
|
168
|
+
}
|
169
|
+
htmlReporter.initialize();
|
170
|
+
env.execute();
|
171
|
+
};
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Helper function for readability above.
|
175
|
+
*/
|
176
|
+
function extend(destination, source) {
|
177
|
+
for (var property in source) destination[property] = source[property];
|
178
|
+
return destination;
|
179
|
+
}
|
180
|
+
|
181
|
+
}());
|
@@ -0,0 +1,160 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008-2013 Pivotal Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
function getJasmineRequireObj() {
|
24
|
+
if (typeof module !== "undefined" && module.exports) {
|
25
|
+
return exports;
|
26
|
+
} else {
|
27
|
+
window.jasmineRequire = window.jasmineRequire || {};
|
28
|
+
return window.jasmineRequire;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
getJasmineRequireObj().console = function(jRequire, j$) {
|
33
|
+
j$.ConsoleReporter = jRequire.ConsoleReporter();
|
34
|
+
};
|
35
|
+
|
36
|
+
getJasmineRequireObj().ConsoleReporter = function() {
|
37
|
+
|
38
|
+
var noopTimer = {
|
39
|
+
start: function(){},
|
40
|
+
elapsed: function(){ return 0; }
|
41
|
+
};
|
42
|
+
|
43
|
+
function ConsoleReporter(options) {
|
44
|
+
var print = options.print,
|
45
|
+
showColors = options.showColors || false,
|
46
|
+
onComplete = options.onComplete || function() {},
|
47
|
+
timer = options.timer || noopTimer,
|
48
|
+
specCount,
|
49
|
+
failureCount,
|
50
|
+
failedSpecs = [],
|
51
|
+
pendingCount,
|
52
|
+
ansi = {
|
53
|
+
green: '\x1B[32m',
|
54
|
+
red: '\x1B[31m',
|
55
|
+
yellow: '\x1B[33m',
|
56
|
+
none: '\x1B[0m'
|
57
|
+
};
|
58
|
+
|
59
|
+
this.jasmineStarted = function() {
|
60
|
+
specCount = 0;
|
61
|
+
failureCount = 0;
|
62
|
+
pendingCount = 0;
|
63
|
+
print("Started");
|
64
|
+
printNewline();
|
65
|
+
timer.start();
|
66
|
+
};
|
67
|
+
|
68
|
+
this.jasmineDone = function() {
|
69
|
+
printNewline();
|
70
|
+
for (var i = 0; i < failedSpecs.length; i++) {
|
71
|
+
specFailureDetails(failedSpecs[i]);
|
72
|
+
}
|
73
|
+
|
74
|
+
printNewline();
|
75
|
+
var specCounts = specCount + " " + plural("spec", specCount) + ", " +
|
76
|
+
failureCount + " " + plural("failure", failureCount);
|
77
|
+
|
78
|
+
if (pendingCount) {
|
79
|
+
specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount);
|
80
|
+
}
|
81
|
+
|
82
|
+
print(specCounts);
|
83
|
+
|
84
|
+
printNewline();
|
85
|
+
var seconds = timer.elapsed() / 1000;
|
86
|
+
print("Finished in " + seconds + " " + plural("second", seconds));
|
87
|
+
|
88
|
+
printNewline();
|
89
|
+
|
90
|
+
onComplete(failureCount === 0);
|
91
|
+
};
|
92
|
+
|
93
|
+
this.specDone = function(result) {
|
94
|
+
specCount++;
|
95
|
+
|
96
|
+
if (result.status == "pending") {
|
97
|
+
pendingCount++;
|
98
|
+
print(colored("yellow", "*"));
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
|
102
|
+
if (result.status == "passed") {
|
103
|
+
print(colored("green", '.'));
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (result.status == "failed") {
|
108
|
+
failureCount++;
|
109
|
+
failedSpecs.push(result);
|
110
|
+
print(colored("red", 'F'));
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
return this;
|
115
|
+
|
116
|
+
function printNewline() {
|
117
|
+
print("\n");
|
118
|
+
}
|
119
|
+
|
120
|
+
function colored(color, str) {
|
121
|
+
return showColors ? (ansi[color] + str + ansi.none) : str;
|
122
|
+
}
|
123
|
+
|
124
|
+
function plural(str, count) {
|
125
|
+
return count == 1 ? str : str + "s";
|
126
|
+
}
|
127
|
+
|
128
|
+
function repeat(thing, times) {
|
129
|
+
var arr = [];
|
130
|
+
for (var i = 0; i < times; i++) {
|
131
|
+
arr.push(thing);
|
132
|
+
}
|
133
|
+
return arr;
|
134
|
+
}
|
135
|
+
|
136
|
+
function indent(str, spaces) {
|
137
|
+
var lines = (str || '').split("\n");
|
138
|
+
var newArr = [];
|
139
|
+
for (var i = 0; i < lines.length; i++) {
|
140
|
+
newArr.push(repeat(" ", spaces).join("") + lines[i]);
|
141
|
+
}
|
142
|
+
return newArr.join("\n");
|
143
|
+
}
|
144
|
+
|
145
|
+
function specFailureDetails(result) {
|
146
|
+
printNewline();
|
147
|
+
print(result.fullName);
|
148
|
+
|
149
|
+
for (var i = 0; i < result.failedExpectations.length; i++) {
|
150
|
+
var failedExpectation = result.failedExpectations[i];
|
151
|
+
printNewline();
|
152
|
+
print(indent(failedExpectation.stack, 2));
|
153
|
+
}
|
154
|
+
|
155
|
+
printNewline();
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
return ConsoleReporter;
|
160
|
+
};
|
@@ -0,0 +1,359 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008-2013 Pivotal Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
jasmineRequire.html = function(j$) {
|
24
|
+
j$.ResultsNode = jasmineRequire.ResultsNode();
|
25
|
+
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
26
|
+
j$.QueryString = jasmineRequire.QueryString();
|
27
|
+
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
28
|
+
};
|
29
|
+
|
30
|
+
jasmineRequire.HtmlReporter = function(j$) {
|
31
|
+
|
32
|
+
var noopTimer = {
|
33
|
+
start: function() {},
|
34
|
+
elapsed: function() { return 0; }
|
35
|
+
};
|
36
|
+
|
37
|
+
function HtmlReporter(options) {
|
38
|
+
var env = options.env || {},
|
39
|
+
getContainer = options.getContainer,
|
40
|
+
createElement = options.createElement,
|
41
|
+
createTextNode = options.createTextNode,
|
42
|
+
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
43
|
+
timer = options.timer || noopTimer,
|
44
|
+
results = [],
|
45
|
+
specsExecuted = 0,
|
46
|
+
failureCount = 0,
|
47
|
+
pendingSpecCount = 0,
|
48
|
+
htmlReporterMain,
|
49
|
+
symbols;
|
50
|
+
|
51
|
+
this.initialize = function() {
|
52
|
+
htmlReporterMain = createDom("div", {className: "html-reporter"},
|
53
|
+
createDom("div", {className: "banner"},
|
54
|
+
createDom("span", {className: "title"}, "Jasmine"),
|
55
|
+
createDom("span", {className: "version"}, j$.version)
|
56
|
+
),
|
57
|
+
createDom("ul", {className: "symbol-summary"}),
|
58
|
+
createDom("div", {className: "alert"}),
|
59
|
+
createDom("div", {className: "results"},
|
60
|
+
createDom("div", {className: "failures"})
|
61
|
+
)
|
62
|
+
);
|
63
|
+
getContainer().appendChild(htmlReporterMain);
|
64
|
+
|
65
|
+
symbols = find(".symbol-summary");
|
66
|
+
};
|
67
|
+
|
68
|
+
var totalSpecsDefined;
|
69
|
+
this.jasmineStarted = function(options) {
|
70
|
+
totalSpecsDefined = options.totalSpecsDefined || 0;
|
71
|
+
timer.start();
|
72
|
+
};
|
73
|
+
|
74
|
+
var summary = createDom("div", {className: "summary"});
|
75
|
+
|
76
|
+
var topResults = new j$.ResultsNode({}, "", null),
|
77
|
+
currentParent = topResults;
|
78
|
+
|
79
|
+
this.suiteStarted = function(result) {
|
80
|
+
currentParent.addChild(result, "suite");
|
81
|
+
currentParent = currentParent.last();
|
82
|
+
};
|
83
|
+
|
84
|
+
this.suiteDone = function(result) {
|
85
|
+
if (currentParent == topResults) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
|
89
|
+
currentParent = currentParent.parent;
|
90
|
+
};
|
91
|
+
|
92
|
+
this.specStarted = function(result) {
|
93
|
+
currentParent.addChild(result, "spec");
|
94
|
+
};
|
95
|
+
|
96
|
+
var failures = [];
|
97
|
+
this.specDone = function(result) {
|
98
|
+
if (result.status != "disabled") {
|
99
|
+
specsExecuted++;
|
100
|
+
}
|
101
|
+
|
102
|
+
symbols.appendChild(createDom("li", {
|
103
|
+
className: result.status,
|
104
|
+
id: "spec_" + result.id,
|
105
|
+
title: result.fullName
|
106
|
+
}
|
107
|
+
));
|
108
|
+
|
109
|
+
if (result.status == "failed") {
|
110
|
+
failureCount++;
|
111
|
+
|
112
|
+
var failure =
|
113
|
+
createDom("div", {className: "spec-detail failed"},
|
114
|
+
createDom("div", {className: "description"},
|
115
|
+
createDom("a", {title: result.fullName, href: specHref(result)}, result.fullName)
|
116
|
+
),
|
117
|
+
createDom("div", {className: "messages"})
|
118
|
+
);
|
119
|
+
var messages = failure.childNodes[1];
|
120
|
+
|
121
|
+
for (var i = 0; i < result.failedExpectations.length; i++) {
|
122
|
+
var expectation = result.failedExpectations[i];
|
123
|
+
messages.appendChild(createDom("div", {className: "result-message"}, expectation.message));
|
124
|
+
messages.appendChild(createDom("div", {className: "stack-trace"}, expectation.stack));
|
125
|
+
}
|
126
|
+
|
127
|
+
failures.push(failure);
|
128
|
+
}
|
129
|
+
|
130
|
+
if (result.status == "pending") {
|
131
|
+
pendingSpecCount++;
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
135
|
+
this.jasmineDone = function() {
|
136
|
+
var banner = find(".banner");
|
137
|
+
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + timer.elapsed() / 1000 + "s"));
|
138
|
+
|
139
|
+
var alert = find(".alert");
|
140
|
+
|
141
|
+
alert.appendChild(createDom("span", { className: "exceptions" },
|
142
|
+
createDom("label", { className: "label", 'for': "raise-exceptions" }, "raise exceptions"),
|
143
|
+
createDom("input", {
|
144
|
+
className: "raise",
|
145
|
+
id: "raise-exceptions",
|
146
|
+
type: "checkbox"
|
147
|
+
})
|
148
|
+
));
|
149
|
+
var checkbox = find("input");
|
150
|
+
|
151
|
+
checkbox.checked = !env.catchingExceptions();
|
152
|
+
checkbox.onclick = onRaiseExceptionsClick;
|
153
|
+
|
154
|
+
if (specsExecuted < totalSpecsDefined) {
|
155
|
+
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
156
|
+
alert.appendChild(
|
157
|
+
createDom("span", {className: "bar skipped"},
|
158
|
+
createDom("a", {href: "?", title: "Run all specs"}, skippedMessage)
|
159
|
+
)
|
160
|
+
);
|
161
|
+
}
|
162
|
+
var statusBarMessage = "" + pluralize("spec", specsExecuted) + ", " + pluralize("failure", failureCount);
|
163
|
+
if (pendingSpecCount) { statusBarMessage += ", " + pluralize("pending spec", pendingSpecCount); }
|
164
|
+
|
165
|
+
var statusBarClassName = "bar " + ((failureCount > 0) ? "failed" : "passed");
|
166
|
+
alert.appendChild(createDom("span", {className: statusBarClassName}, statusBarMessage));
|
167
|
+
|
168
|
+
var results = find(".results");
|
169
|
+
results.appendChild(summary);
|
170
|
+
|
171
|
+
summaryList(topResults, summary);
|
172
|
+
|
173
|
+
function summaryList(resultsTree, domParent) {
|
174
|
+
var specListNode;
|
175
|
+
for (var i = 0; i < resultsTree.children.length; i++) {
|
176
|
+
var resultNode = resultsTree.children[i];
|
177
|
+
if (resultNode.type == "suite") {
|
178
|
+
var suiteListNode = createDom("ul", {className: "suite", id: "suite-" + resultNode.result.id},
|
179
|
+
createDom("li", {className: "suite-detail"},
|
180
|
+
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
|
181
|
+
)
|
182
|
+
);
|
183
|
+
|
184
|
+
summaryList(resultNode, suiteListNode);
|
185
|
+
domParent.appendChild(suiteListNode);
|
186
|
+
}
|
187
|
+
if (resultNode.type == "spec") {
|
188
|
+
if (domParent.getAttribute("class") != "specs") {
|
189
|
+
specListNode = createDom("ul", {className: "specs"});
|
190
|
+
domParent.appendChild(specListNode);
|
191
|
+
}
|
192
|
+
specListNode.appendChild(
|
193
|
+
createDom("li", {
|
194
|
+
className: resultNode.result.status,
|
195
|
+
id: "spec-" + resultNode.result.id
|
196
|
+
},
|
197
|
+
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
|
198
|
+
)
|
199
|
+
);
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
if (failures.length) {
|
205
|
+
alert.appendChild(
|
206
|
+
createDom('span', {className: "menu bar spec-list"},
|
207
|
+
createDom("span", {}, "Spec List | "),
|
208
|
+
createDom('a', {className: "failures-menu", href: "#"}, "Failures")));
|
209
|
+
alert.appendChild(
|
210
|
+
createDom('span', {className: "menu bar failure-list"},
|
211
|
+
createDom('a', {className: "spec-list-menu", href: "#"}, "Spec List"),
|
212
|
+
createDom("span", {}, " | Failures ")));
|
213
|
+
|
214
|
+
find(".failures-menu").onclick = function() {
|
215
|
+
setMenuModeTo('failure-list');
|
216
|
+
};
|
217
|
+
find(".spec-list-menu").onclick = function() {
|
218
|
+
setMenuModeTo('spec-list');
|
219
|
+
};
|
220
|
+
|
221
|
+
setMenuModeTo('failure-list');
|
222
|
+
|
223
|
+
var failureNode = find(".failures");
|
224
|
+
for (var i = 0; i < failures.length; i++) {
|
225
|
+
failureNode.appendChild(failures[i]);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
};
|
229
|
+
|
230
|
+
return this;
|
231
|
+
|
232
|
+
function find(selector) {
|
233
|
+
return getContainer().querySelector(selector);
|
234
|
+
}
|
235
|
+
|
236
|
+
function createDom(type, attrs, childrenVarArgs) {
|
237
|
+
var el = createElement(type);
|
238
|
+
|
239
|
+
for (var i = 2; i < arguments.length; i++) {
|
240
|
+
var child = arguments[i];
|
241
|
+
|
242
|
+
if (typeof child === 'string') {
|
243
|
+
el.appendChild(createTextNode(child));
|
244
|
+
} else {
|
245
|
+
if (child) {
|
246
|
+
el.appendChild(child);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
for (var attr in attrs) {
|
252
|
+
if (attr == "className") {
|
253
|
+
el[attr] = attrs[attr];
|
254
|
+
} else {
|
255
|
+
el.setAttribute(attr, attrs[attr]);
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
return el;
|
260
|
+
}
|
261
|
+
|
262
|
+
function pluralize(singular, count) {
|
263
|
+
var word = (count == 1 ? singular : singular + "s");
|
264
|
+
|
265
|
+
return "" + count + " " + word;
|
266
|
+
}
|
267
|
+
|
268
|
+
function specHref(result) {
|
269
|
+
return "?spec=" + encodeURIComponent(result.fullName);
|
270
|
+
}
|
271
|
+
|
272
|
+
function setMenuModeTo(mode) {
|
273
|
+
htmlReporterMain.setAttribute("class", "html-reporter " + mode);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
return HtmlReporter;
|
278
|
+
};
|
279
|
+
|
280
|
+
jasmineRequire.HtmlSpecFilter = function() {
|
281
|
+
function HtmlSpecFilter(options) {
|
282
|
+
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
283
|
+
var filterPattern = new RegExp(filterString);
|
284
|
+
|
285
|
+
this.matches = function(specName) {
|
286
|
+
return filterPattern.test(specName);
|
287
|
+
};
|
288
|
+
}
|
289
|
+
|
290
|
+
return HtmlSpecFilter;
|
291
|
+
};
|
292
|
+
|
293
|
+
jasmineRequire.ResultsNode = function() {
|
294
|
+
function ResultsNode(result, type, parent) {
|
295
|
+
this.result = result;
|
296
|
+
this.type = type;
|
297
|
+
this.parent = parent;
|
298
|
+
|
299
|
+
this.children = [];
|
300
|
+
|
301
|
+
this.addChild = function(result, type) {
|
302
|
+
this.children.push(new ResultsNode(result, type, this));
|
303
|
+
};
|
304
|
+
|
305
|
+
this.last = function() {
|
306
|
+
return this.children[this.children.length - 1];
|
307
|
+
};
|
308
|
+
}
|
309
|
+
|
310
|
+
return ResultsNode;
|
311
|
+
};
|
312
|
+
|
313
|
+
jasmineRequire.QueryString = function() {
|
314
|
+
function QueryString(options) {
|
315
|
+
|
316
|
+
this.setParam = function(key, value) {
|
317
|
+
var paramMap = queryStringToParamMap();
|
318
|
+
paramMap[key] = value;
|
319
|
+
options.getWindowLocation().search = toQueryString(paramMap);
|
320
|
+
};
|
321
|
+
|
322
|
+
this.getParam = function(key) {
|
323
|
+
return queryStringToParamMap()[key];
|
324
|
+
};
|
325
|
+
|
326
|
+
return this;
|
327
|
+
|
328
|
+
function toQueryString(paramMap) {
|
329
|
+
var qStrPairs = [];
|
330
|
+
for (var prop in paramMap) {
|
331
|
+
qStrPairs.push(encodeURIComponent(prop) + "=" + encodeURIComponent(paramMap[prop]));
|
332
|
+
}
|
333
|
+
return "?" + qStrPairs.join('&');
|
334
|
+
}
|
335
|
+
|
336
|
+
function queryStringToParamMap() {
|
337
|
+
var paramStr = options.getWindowLocation().search.substring(1),
|
338
|
+
params = [],
|
339
|
+
paramMap = {};
|
340
|
+
|
341
|
+
if (paramStr.length > 0) {
|
342
|
+
params = paramStr.split('&');
|
343
|
+
for (var i = 0; i < params.length; i++) {
|
344
|
+
var p = params[i].split('=');
|
345
|
+
var value = decodeURIComponent(p[1]);
|
346
|
+
if (value === "true" || value === "false") {
|
347
|
+
value = JSON.parse(value);
|
348
|
+
}
|
349
|
+
paramMap[decodeURIComponent(p[0])] = value;
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
353
|
+
return paramMap;
|
354
|
+
}
|
355
|
+
|
356
|
+
}
|
357
|
+
|
358
|
+
return QueryString;
|
359
|
+
};
|