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
Binary file
|
@@ -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.
|
File without changes
|
File without changes
|
File without changes
|
@@ -6,9 +6,10 @@ module Snapdragon
|
|
6
6
|
class CommandLineParser
|
7
7
|
def self.parse(args)
|
8
8
|
options = OpenStruct.new
|
9
|
-
options.format = "console"
|
9
|
+
options.format = "console"
|
10
10
|
options.color = true
|
11
11
|
options.pattern = "spec/**/*_spec.js"
|
12
|
+
options.jasmine_ver = "2"
|
12
13
|
|
13
14
|
opts = OptionParser.new do |opts|
|
14
15
|
opts.banner = "Usage: snapdragon [options] [files or directories]"
|
@@ -21,12 +22,15 @@ module Snapdragon
|
|
21
22
|
opts.on('-f', '--format [FORMAT]', "set output format") do |format|
|
22
23
|
options.format = format
|
23
24
|
end
|
24
|
-
opts.on('-
|
25
|
-
options.color =
|
25
|
+
opts.on('-N', "--nocolor", '--nocolour', 'Enable color in the output.') do
|
26
|
+
options.color = false
|
26
27
|
end
|
27
28
|
opts.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.js").') do |pattern|
|
28
29
|
options.pattern = pattern
|
29
30
|
end
|
31
|
+
opts.on('-J1', '--jasminev1', 'Use Jasmine v1.3.1 instead of the default v2.x.') do
|
32
|
+
options.jasmine_ver = "1"
|
33
|
+
end
|
30
34
|
end
|
31
35
|
opts.parse!(args)
|
32
36
|
options
|
@@ -1,162 +1,163 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
passedCount,
|
8
|
-
failedSpecs = [],
|
9
|
-
pendingSpecs = [],
|
10
|
-
pendingCount,
|
11
|
-
startTimestamp,
|
12
|
-
endTimestamp
|
13
|
-
ansi = {
|
14
|
-
green: '\033[32m',
|
15
|
-
red: '\033[31m',
|
16
|
-
yellow: '\033[33m',
|
17
|
-
none: '\033[0m'
|
18
|
-
};
|
19
|
-
|
20
|
-
function printNewline() {
|
21
|
-
print("");
|
1
|
+
function getJasmineRequireObj() {
|
2
|
+
if (typeof module !== "undefined" && module.exports) {
|
3
|
+
return exports;
|
4
|
+
} else {
|
5
|
+
window.jasmineRequire = window.jasmineRequire || {};
|
6
|
+
return window.jasmineRequire;
|
22
7
|
}
|
8
|
+
}
|
23
9
|
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
getJasmineRequireObj().console = function(jRequire, j$) {
|
11
|
+
j$.SnapdragonConsoleReporter = jRequire.SnapdragonConsoleReporter();
|
12
|
+
};
|
27
13
|
|
28
|
-
|
29
|
-
return count == 1 ? str : str + "s";
|
30
|
-
}
|
14
|
+
getJasmineRequireObj().SnapdragonConsoleReporter = function() {
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
return arr;
|
38
|
-
}
|
16
|
+
var noopTimer = {
|
17
|
+
start: function(){},
|
18
|
+
elapsed: function(){ return 0; }
|
19
|
+
};
|
39
20
|
|
40
|
-
function
|
41
|
-
var
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
21
|
+
return function(options) {
|
22
|
+
var print = options.print || function(msg) {console.log(msg);},
|
23
|
+
showColors = options.showColors || false,
|
24
|
+
onComplete = options.onComplete || function() {},
|
25
|
+
timer = options.timer || new jasmine.Timer() || noopTimer,
|
26
|
+
specCount,
|
27
|
+
failureCount,
|
28
|
+
failedSpecs = [],
|
29
|
+
pendingCount,
|
30
|
+
pendingSpecs = [],
|
31
|
+
passedCount,
|
32
|
+
specStatus = [],
|
33
|
+
ansi = {
|
34
|
+
green: '\x1B[32m',
|
35
|
+
red: '\x1B[31m',
|
36
|
+
yellow: '\x1B[33m',
|
37
|
+
none: '\x1B[0m',
|
38
|
+
red_bold: '\x1B[31;1m'
|
39
|
+
};
|
40
|
+
|
41
|
+
this.jasmineStarted = function() {
|
42
|
+
specCount = 0;
|
43
|
+
failureCount = 0;
|
44
|
+
pendingCount = 0;
|
45
|
+
passedCount = 0;
|
46
|
+
print("Running specs...");
|
47
|
+
printNewline();
|
48
|
+
timer.start();
|
49
|
+
};
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
+
this.jasmineDone = function() {
|
52
|
+
print(specStatus.join(""));
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
if (failedSpecs.length > 0) {
|
55
|
+
printNewline();
|
56
|
+
for (var i = 0; i < failedSpecs.length; i++) {
|
57
|
+
specFailureDetails(failedSpecs[i], i + 1);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
printNewline();
|
62
|
+
var specCounts = specCount + " " + plural("spec", specCount) + ", " +
|
63
|
+
failureCount + " " + plural("failure", failureCount);
|
64
|
+
|
65
|
+
if (pendingCount) {
|
66
|
+
specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount);
|
67
|
+
}
|
68
|
+
|
69
|
+
if (failureCount > 0) {
|
70
|
+
print(colored("red", specCounts));
|
71
|
+
} else if (pendingCount > 0) {
|
72
|
+
print(colored("yellow", specCounts));
|
57
73
|
} else {
|
58
|
-
print(
|
74
|
+
print(colored("green", specCounts));
|
59
75
|
}
|
60
|
-
}
|
61
|
-
printNewline();
|
62
|
-
}
|
63
76
|
|
64
|
-
|
65
|
-
|
66
|
-
printNewline();
|
67
|
-
}
|
77
|
+
var seconds = timer.elapsed() / 1000;
|
78
|
+
print("Finished in " + seconds + " " + plural("second", seconds));
|
68
79
|
|
69
|
-
|
70
|
-
var div = document.createElement('div');
|
71
|
-
div.id = 'testscomplete';
|
72
|
-
document.body.appendChild(div);
|
73
|
-
}
|
80
|
+
printNewline();
|
74
81
|
|
75
|
-
|
76
|
-
return stackTraceString.replace(/\s*at\s*http:\/\/127.0.0.1:\d+\/jasmine-core\/jasmine\.js:\d+\s*/g, "");
|
77
|
-
}
|
82
|
+
onComplete(failureCount === 0);
|
78
83
|
|
79
|
-
|
84
|
+
signalCapybaraTestsFinishedRunning();
|
85
|
+
};
|
80
86
|
|
81
|
-
|
82
|
-
|
87
|
+
this.specDone = function(result) {
|
88
|
+
specCount++;
|
83
89
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
print("Running examples...");
|
91
|
-
printNewline();
|
92
|
-
};
|
90
|
+
if (result.status == "pending") {
|
91
|
+
pendingCount++;
|
92
|
+
pendingSpecs.push(result);
|
93
|
+
specStatus.push(colored("yellow", "*"));
|
94
|
+
return;
|
95
|
+
}
|
93
96
|
|
94
|
-
|
95
|
-
|
97
|
+
if (result.status == "passed") {
|
98
|
+
passedCount++;
|
99
|
+
specStatus.push(colored("green", "."));
|
100
|
+
return;
|
101
|
+
}
|
96
102
|
|
97
|
-
|
98
|
-
|
103
|
+
if (result.status == "failed") {
|
104
|
+
failureCount++;
|
105
|
+
failedSpecs.push(result);
|
106
|
+
specStatus.push(colored("red", "F"));
|
107
|
+
}
|
108
|
+
};
|
99
109
|
|
100
|
-
|
101
|
-
var results = spec.results();
|
110
|
+
return this;
|
102
111
|
|
103
|
-
|
104
|
-
|
112
|
+
function printNewline() {
|
113
|
+
print("");
|
105
114
|
}
|
106
115
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
failureCount++;
|
114
|
-
failedSpecs.push(spec);
|
116
|
+
function colored(color, str) {
|
117
|
+
return showColors ? (ansi[color] + str + ansi.none) : str;
|
118
|
+
}
|
119
|
+
|
120
|
+
function plural(str, count) {
|
121
|
+
return count == 1 ? str : str + "s";
|
115
122
|
}
|
116
|
-
};
|
117
123
|
|
118
|
-
|
119
|
-
|
124
|
+
function repeat(thing, times) {
|
125
|
+
var arr = [];
|
126
|
+
for (var i = 0; i < times; i++) {
|
127
|
+
arr.push(thing);
|
128
|
+
}
|
129
|
+
return arr;
|
130
|
+
}
|
120
131
|
|
121
|
-
|
122
|
-
|
123
|
-
|
132
|
+
function indent(str, spaces) {
|
133
|
+
var lines = (str || '').split("\n");
|
134
|
+
var newArr = [];
|
135
|
+
for (var i = 0; i < lines.length; i++) {
|
136
|
+
newArr.push(repeat(" ", spaces).join("") + lines[i]);
|
137
|
+
}
|
138
|
+
return newArr.join("\n");
|
139
|
+
}
|
124
140
|
|
125
|
-
|
126
|
-
|
127
|
-
|
141
|
+
function specFailureDetails(result, index) {
|
142
|
+
printNewline();
|
143
|
+
print(colored("red_bold", indent(index + ") " + result.fullName, 2)));
|
128
144
|
|
129
|
-
|
130
|
-
|
131
|
-
|
145
|
+
for (var i = 0; i < result.failedExpectations.length; i++) {
|
146
|
+
var failedExpectation = result.failedExpectations[i];
|
147
|
+
print(indent(trimStackTrace(failedExpectation.stack), 6));
|
148
|
+
}
|
132
149
|
|
133
|
-
if (failureCount > 0) {
|
134
|
-
print("Failures:");
|
135
150
|
printNewline();
|
136
151
|
}
|
137
152
|
|
138
|
-
|
139
|
-
|
153
|
+
function trimStackTrace(stackTraceString) {
|
154
|
+
return stackTraceString.replace(/\s*at\s(?:\w+\s)?\(?http:\/\/127.0.0.1:\d+\/jasmine\/(?:jasmine|boot)\.js:\d+\)?/g, "");
|
140
155
|
}
|
141
156
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
}
|
147
|
-
|
148
|
-
var seconds = (endTimestamp - startTimestamp) / 1000.0;
|
149
|
-
print("Finished in " + seconds + " " + plural("second", seconds));
|
150
|
-
|
151
|
-
if (failureCount > 0) { // have any failures
|
152
|
-
print(colored("red", specCounts));
|
153
|
-
// } else if (pendingCount > 0) {
|
154
|
-
// print(colored("yellow", specCounts));
|
155
|
-
} else {
|
156
|
-
print(colored("green", specCounts));
|
157
|
+
function signalCapybaraTestsFinishedRunning() {
|
158
|
+
var div = document.createElement('div');
|
159
|
+
div.id = 'testscomplete';
|
160
|
+
document.body.appendChild(div);
|
157
161
|
}
|
158
|
-
|
159
|
-
onComplete();
|
160
|
-
signalCapybaraTestsFinishedRunning();
|
161
|
-
};
|
162
|
+
}
|
162
163
|
};
|
@@ -0,0 +1,162 @@
|
|
1
|
+
jasmine.SnapdragonConsoleReporter = function(options) {
|
2
|
+
var print = function(msg) { console.log(msg); },
|
3
|
+
showColors = options.showColors,
|
4
|
+
onComplete = options.onComplete || function() {},
|
5
|
+
specCount,
|
6
|
+
failureCount,
|
7
|
+
passedCount,
|
8
|
+
failedSpecs = [],
|
9
|
+
pendingSpecs = [],
|
10
|
+
pendingCount,
|
11
|
+
startTimestamp,
|
12
|
+
endTimestamp
|
13
|
+
ansi = {
|
14
|
+
green: '\033[32m',
|
15
|
+
red: '\033[31m',
|
16
|
+
yellow: '\033[33m',
|
17
|
+
none: '\033[0m'
|
18
|
+
};
|
19
|
+
|
20
|
+
function printNewline() {
|
21
|
+
print("");
|
22
|
+
}
|
23
|
+
|
24
|
+
function colored(color, str) {
|
25
|
+
return showColors ? (ansi[color] + str + ansi.none) : str;
|
26
|
+
}
|
27
|
+
|
28
|
+
function plural(str, count) {
|
29
|
+
return count == 1 ? str : str + "s";
|
30
|
+
}
|
31
|
+
|
32
|
+
function repeat(thing, times) {
|
33
|
+
var arr = [];
|
34
|
+
for (var i = 0; i < times; i++) {
|
35
|
+
arr.push(thing);
|
36
|
+
}
|
37
|
+
return arr;
|
38
|
+
}
|
39
|
+
|
40
|
+
function indent(str, spaces) {
|
41
|
+
var lines = (str || '').split("\n");
|
42
|
+
var newArr = [];
|
43
|
+
for (var i = 0; i < lines.length; i++) {
|
44
|
+
newArr.push(repeat(" ", spaces).join("") + lines[i]);
|
45
|
+
}
|
46
|
+
return newArr.join("\n");
|
47
|
+
}
|
48
|
+
|
49
|
+
function specFailureDetails(spec, failure_number) {
|
50
|
+
print(indent(failure_number + ") " + spec.getFullName(), 2));
|
51
|
+
|
52
|
+
var resultItems = spec.results().getItems();
|
53
|
+
for (var i = 0; i < resultItems.length; i++) {
|
54
|
+
var result = resultItems[i];
|
55
|
+
if (result.trace.stack) {
|
56
|
+
print(indent(colored("red", trimStackTrace(result.trace.stack)), 6));
|
57
|
+
} else {
|
58
|
+
print(indent(colored("red", result.message), 6));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
printNewline();
|
62
|
+
}
|
63
|
+
|
64
|
+
function specPendingDetails(spec) {
|
65
|
+
print(indent(colored("yellow", spec.getFullName()), 2));
|
66
|
+
printNewline();
|
67
|
+
}
|
68
|
+
|
69
|
+
function signalCapybaraTestsFinishedRunning() {
|
70
|
+
var div = document.createElement('div');
|
71
|
+
div.id = 'testscomplete';
|
72
|
+
document.body.appendChild(div);
|
73
|
+
}
|
74
|
+
|
75
|
+
function trimStackTrace(stackTraceString) {
|
76
|
+
return stackTraceString.replace(/\s*at\s*http:\/\/127.0.0.1:\d+\/jasmine_v1\/jasmine\.js:\d+\s*/g, "");
|
77
|
+
}
|
78
|
+
|
79
|
+
// Jasmine Hooks
|
80
|
+
|
81
|
+
this.log = function() {
|
82
|
+
};
|
83
|
+
|
84
|
+
this.reportRunnerStarting = function() {
|
85
|
+
startTimestamp = new Date().getTime();
|
86
|
+
specCount = 0;
|
87
|
+
failureCount = 0;
|
88
|
+
passedCount = 0;
|
89
|
+
pendingCount = 0;
|
90
|
+
print("Running examples...");
|
91
|
+
printNewline();
|
92
|
+
};
|
93
|
+
|
94
|
+
this.reportSuiteResults = function(suite) {
|
95
|
+
};
|
96
|
+
|
97
|
+
this.reportSpecStarting = function() {
|
98
|
+
};
|
99
|
+
|
100
|
+
this.reportSpecResults = function(spec) {
|
101
|
+
var results = spec.results();
|
102
|
+
|
103
|
+
if (!results.skipped) { // not pending
|
104
|
+
specCount++;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (results.skipped) { // when you filter out tests with spec query param
|
108
|
+
pendingCount++;
|
109
|
+
pendingSpecs.push(spec);
|
110
|
+
} else if (results.passed()) { // passed
|
111
|
+
passedCount++;
|
112
|
+
} else { // failed
|
113
|
+
failureCount++;
|
114
|
+
failedSpecs.push(spec);
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
this.reportRunnerResults = function(options) {
|
119
|
+
endTimestamp = new Date().getTime();
|
120
|
+
|
121
|
+
// I have commented out the pending section below because v1.3.1 of
|
122
|
+
// jasmine doesn't have a concept of pending. It has a concept of
|
123
|
+
// skipped when you filter tests using the spec query param.
|
124
|
+
|
125
|
+
// if (pendingCount > 0) {
|
126
|
+
// print("Pending:");
|
127
|
+
// }
|
128
|
+
|
129
|
+
// for (var i = 0; i < pendingSpecs.length; i++) {
|
130
|
+
// specPendingDetails(pendingSpecs[i]);
|
131
|
+
// }
|
132
|
+
|
133
|
+
if (failureCount > 0) {
|
134
|
+
print("Failures:");
|
135
|
+
printNewline();
|
136
|
+
}
|
137
|
+
|
138
|
+
for (var i = 0; i < failedSpecs.length; i++) {
|
139
|
+
specFailureDetails(failedSpecs[i], i + 1);
|
140
|
+
}
|
141
|
+
|
142
|
+
var specCounts = specCount + " " + plural("example", specCount) + ", " + failureCount + " " + plural("failure", failureCount);
|
143
|
+
|
144
|
+
if (pendingCount) {
|
145
|
+
specCounts += ", " + pendingCount + " skipped";
|
146
|
+
}
|
147
|
+
|
148
|
+
var seconds = (endTimestamp - startTimestamp) / 1000.0;
|
149
|
+
print("Finished in " + seconds + " " + plural("second", seconds));
|
150
|
+
|
151
|
+
if (failureCount > 0) { // have any failures
|
152
|
+
print(colored("red", specCounts));
|
153
|
+
// } else if (pendingCount > 0) {
|
154
|
+
// print(colored("yellow", specCounts));
|
155
|
+
} else {
|
156
|
+
print(colored("green", specCounts));
|
157
|
+
}
|
158
|
+
|
159
|
+
onComplete();
|
160
|
+
signalCapybaraTestsFinishedRunning();
|
161
|
+
};
|
162
|
+
};
|