jazrb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +134 -0
- data/bin/autojaz +4 -0
- data/bin/jazrb +230 -0
- data/doc/jasmine/files.html +460 -0
- data/doc/jasmine/index.html +322 -0
- data/doc/jasmine/symbols/_global_.html +1083 -0
- data/doc/jasmine/symbols/jasmine.Block.html +417 -0
- data/doc/jasmine/symbols/jasmine.Clock.html +678 -0
- data/doc/jasmine/symbols/jasmine.Env.html +1135 -0
- data/doc/jasmine/symbols/jasmine.EnvjsReporter.html +328 -0
- data/doc/jasmine/symbols/jasmine.JsApiReporter.html +822 -0
- data/doc/jasmine/symbols/jasmine.Matchers.html +1106 -0
- data/doc/jasmine/symbols/jasmine.MultiReporter.html +394 -0
- data/doc/jasmine/symbols/jasmine.NestedResults.html +710 -0
- data/doc/jasmine/symbols/jasmine.Reporter.html +574 -0
- data/doc/jasmine/symbols/jasmine.Runner.html +710 -0
- data/doc/jasmine/symbols/jasmine.Spec.html +1372 -0
- data/doc/jasmine/symbols/jasmine.Spy.html +855 -0
- data/doc/jasmine/symbols/jasmine.Suite.html +705 -0
- data/doc/jasmine/symbols/jasmine.XMLReporter.html +328 -0
- data/doc/jasmine/symbols/jasmine.html +1359 -0
- data/doc/jasmine/symbols/jasmine.util.html +535 -0
- data/doc/jasmine/symbols/src/lib_EnvjsReporter.js.html +149 -0
- data/doc/jasmine/symbols/src/lib_TrivialReporter.js.html +127 -0
- data/doc/jasmine/symbols/src/lib_XMLReporter.js.html +210 -0
- data/doc/jasmine/symbols/src/src_Block.js.html +35 -0
- data/doc/jasmine/symbols/src/src_Env.js.html +233 -0
- data/doc/jasmine/symbols/src/src_JsApiReporter.js.html +110 -0
- data/doc/jasmine/symbols/src/src_Matchers.js.html +399 -0
- data/doc/jasmine/symbols/src/src_MultiReporter.js.html +36 -0
- data/doc/jasmine/symbols/src/src_NestedResults.js.html +88 -0
- data/doc/jasmine/symbols/src/src_PrettyPrinter.js.html +128 -0
- data/doc/jasmine/symbols/src/src_Queue.js.html +119 -0
- data/doc/jasmine/symbols/src/src_Reporter.js.html +35 -0
- data/doc/jasmine/symbols/src/src_Reporters.js.html +51 -0
- data/doc/jasmine/symbols/src/src_Runner.js.html +75 -0
- data/doc/jasmine/symbols/src/src_Spec.js.html +228 -0
- data/doc/jasmine/symbols/src/src_Suite.js.html +77 -0
- data/doc/jasmine/symbols/src/src_WaitsBlock.js.html +21 -0
- data/doc/jasmine/symbols/src/src_WaitsForBlock.js.html +45 -0
- data/doc/jasmine/symbols/src/src_base.js.html +566 -0
- data/doc/jasmine/symbols/src/src_mock-timeout.js.html +185 -0
- data/doc/jasmine/symbols/src/src_util.js.html +75 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/jazrb.rb +55 -0
- data/lib/jazrb/intro.js +46 -0
- data/lib/jazrb/jasmine/EnvjsReporter.js +141 -0
- data/lib/jazrb/jasmine/TrivialReporter.js +155 -0
- data/lib/jazrb/jasmine/XMLReporter.js +241 -0
- data/lib/jazrb/jasmine/consolex.js +28 -0
- data/lib/jazrb/jasmine/jasmine-0.10.0.js +2526 -0
- data/lib/jazrb/jasmine/jasmine.js +2526 -0
- data/lib/jazrb/jasmine/json2.js +478 -0
- data/lib/jazrb/options.rb +26 -0
- data/lib/jazrb/outro.js +3 -0
- data/lib/jazrb/qintro.js +113 -0
- data/lib/jazrb/qoutro.js +3 -0
- data/lib/jazrb/qunit/qunit.css +17 -0
- data/lib/jazrb/qunit/qunit.js +1027 -0
- data/lib/jazrb.rb +0 -0
- data/spec/example/hello_world_spec.js +29 -0
- data/spec/example/nested/HelloWorldSpec.js +13 -0
- data/spec/example/nested/SpecHelper.js +1 -0
- data/spec/example/plain_spec.js +8 -0
- data/spec/example/spec_helper.js +1 -0
- data/spec/spec_helper.js +18 -0
- data/spec/spec_runner.js +143 -0
- data/test/jazrb_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- data/vendor/jasmine/MIT.LICENSE +20 -0
- data/vendor/jasmine/README.markdown +479 -0
- data/vendor/jasmine/Rakefile +155 -0
- data/vendor/jasmine/contrib/ruby/jasmine_runner.rb +334 -0
- data/vendor/jasmine/contrib/ruby/jasmine_spec_builder.rb +153 -0
- data/vendor/jasmine/contrib/ruby/run.html +47 -0
- data/vendor/jasmine/contrib/ruby/spec/jasmine_runner_spec.rb +71 -0
- data/vendor/jasmine/doc/files.html +460 -0
- data/vendor/jasmine/doc/index.html +322 -0
- data/vendor/jasmine/doc/symbols/_global_.html +1083 -0
- data/vendor/jasmine/doc/symbols/jasmine.Block.html +417 -0
- data/vendor/jasmine/doc/symbols/jasmine.Clock.html +678 -0
- data/vendor/jasmine/doc/symbols/jasmine.Env.html +1135 -0
- data/vendor/jasmine/doc/symbols/jasmine.EnvjsReporter.html +328 -0
- data/vendor/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
- data/vendor/jasmine/doc/symbols/jasmine.Matchers.html +1106 -0
- data/vendor/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
- data/vendor/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
- data/vendor/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
- data/vendor/jasmine/doc/symbols/jasmine.Runner.html +710 -0
- data/vendor/jasmine/doc/symbols/jasmine.Spec.html +1372 -0
- data/vendor/jasmine/doc/symbols/jasmine.Spy.html +855 -0
- data/vendor/jasmine/doc/symbols/jasmine.Suite.html +705 -0
- data/vendor/jasmine/doc/symbols/jasmine.XMLReporter.html +328 -0
- data/vendor/jasmine/doc/symbols/jasmine.html +1359 -0
- data/vendor/jasmine/doc/symbols/jasmine.util.html +535 -0
- data/vendor/jasmine/doc/symbols/src/lib_EnvjsReporter.js.html +149 -0
- data/vendor/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +127 -0
- data/vendor/jasmine/doc/symbols/src/lib_XMLReporter.js.html +210 -0
- data/vendor/jasmine/doc/symbols/src/src_Block.js.html +35 -0
- data/vendor/jasmine/doc/symbols/src/src_Env.js.html +233 -0
- data/vendor/jasmine/doc/symbols/src/src_JsApiReporter.js.html +110 -0
- data/vendor/jasmine/doc/symbols/src/src_Matchers.js.html +399 -0
- data/vendor/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
- data/vendor/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
- data/vendor/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +128 -0
- data/vendor/jasmine/doc/symbols/src/src_Queue.js.html +119 -0
- data/vendor/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
- data/vendor/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
- data/vendor/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
- data/vendor/jasmine/doc/symbols/src/src_Spec.js.html +228 -0
- data/vendor/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
- data/vendor/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
- data/vendor/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
- data/vendor/jasmine/doc/symbols/src/src_base.js.html +566 -0
- data/vendor/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
- data/vendor/jasmine/doc/symbols/src/src_util.js.html +75 -0
- data/vendor/jasmine/examples/html/example_suite.html +27 -0
- data/vendor/jasmine/examples/html/spec/example_suite.js +11 -0
- data/vendor/jasmine/examples/ruby/Rakefile +33 -0
- data/vendor/jasmine/examples/ruby/spec/example/example_spec.js +11 -0
- data/vendor/jasmine/examples/ruby/spec/jasmine_helper.rb +41 -0
- data/vendor/jasmine/examples/ruby/spec/jasmine_spec.rb +31 -0
- data/vendor/jasmine/examples/ruby/spec/saucelabs.yml +24 -0
- data/vendor/jasmine/geminstaller.yml +23 -0
- data/vendor/jasmine/images/fail-16.png +0 -0
- data/vendor/jasmine/images/fail.png +0 -0
- data/vendor/jasmine/images/go-16.png +0 -0
- data/vendor/jasmine/images/go.png +0 -0
- data/vendor/jasmine/images/pending-16.png +0 -0
- data/vendor/jasmine/images/pending.png +0 -0
- data/vendor/jasmine/images/question-bk.png +0 -0
- data/vendor/jasmine/images/questionbk-16.png +0 -0
- data/vendor/jasmine/images/spinner.gif +0 -0
- data/vendor/jasmine/jasmine.watchr +70 -0
- data/vendor/jasmine/lib/EnvjsReporter.js +141 -0
- data/vendor/jasmine/lib/TrivialReporter.js +155 -0
- data/vendor/jasmine/lib/XMLReporter.js +241 -0
- data/vendor/jasmine/lib/consolex.js +28 -0
- data/vendor/jasmine/lib/jasmine-0.10.0.js +2526 -0
- data/vendor/jasmine/lib/jasmine.css +86 -0
- data/vendor/jasmine/lib/json2.js +478 -0
- data/vendor/jasmine/spec/jasmine_helper.rb +44 -0
- data/vendor/jasmine/spec/jasmine_spec.rb +31 -0
- data/vendor/jasmine/spec/runner.html +43 -0
- data/vendor/jasmine/spec/runner.js +78 -0
- data/vendor/jasmine/spec/saucelabs.yml +24 -0
- data/vendor/jasmine/spec/suites/EnvSpec.js +71 -0
- data/vendor/jasmine/spec/suites/ExceptionsSpec.js +107 -0
- data/vendor/jasmine/spec/suites/JsApiReporterSpec.js +82 -0
- data/vendor/jasmine/spec/suites/MatchersSpec.js +589 -0
- data/vendor/jasmine/spec/suites/MockClockSpec.js +34 -0
- data/vendor/jasmine/spec/suites/MultiReporterSpec.js +30 -0
- data/vendor/jasmine/spec/suites/NestedResultsSpec.js +54 -0
- data/vendor/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
- data/vendor/jasmine/spec/suites/QueueSpec.js +23 -0
- data/vendor/jasmine/spec/suites/ReporterSpec.js +60 -0
- data/vendor/jasmine/spec/suites/RunnerSpec.js +258 -0
- data/vendor/jasmine/spec/suites/SpecRunningSpec.js +1117 -0
- data/vendor/jasmine/spec/suites/SpecSpec.js +110 -0
- data/vendor/jasmine/spec/suites/SpySpec.js +187 -0
- data/vendor/jasmine/spec/suites/SuiteSpec.js +101 -0
- data/vendor/jasmine/spec/suites/TrivialReporterSpec.js +140 -0
- data/vendor/jasmine/spec/suites/UtilSpec.js +23 -0
- data/vendor/jasmine/src/Block.js +34 -0
- data/vendor/jasmine/src/Env.js +236 -0
- data/vendor/jasmine/src/JsApiReporter.js +103 -0
- data/vendor/jasmine/src/Matchers.js +326 -0
- data/vendor/jasmine/src/MultiReporter.js +28 -0
- data/vendor/jasmine/src/NestedResults.js +99 -0
- data/vendor/jasmine/src/PrettyPrinter.js +122 -0
- data/vendor/jasmine/src/Queue.js +210 -0
- data/vendor/jasmine/src/Reporter.js +27 -0
- data/vendor/jasmine/src/Reporters.js +43 -0
- data/vendor/jasmine/src/Runner.js +68 -0
- data/vendor/jasmine/src/Spec.js +254 -0
- data/vendor/jasmine/src/Suite.js +70 -0
- data/vendor/jasmine/src/WaitsBlock.js +13 -0
- data/vendor/jasmine/src/WaitsForBlock.js +38 -0
- data/vendor/jasmine/src/base.js +604 -0
- data/vendor/jasmine/src/mock-timeout.js +177 -0
- data/vendor/jasmine/src/util.js +67 -0
- data/vendor/jasmine/src/version.json +5 -0
- metadata +279 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
/** JavaScript API reporter.
|
2
|
+
*
|
3
|
+
* @constructor
|
4
|
+
*/
|
5
|
+
jasmine.EnvjsReporter = function() {
|
6
|
+
this.started = false;
|
7
|
+
this.finished = false;
|
8
|
+
this.suites_ = [];
|
9
|
+
this.results_ = {};
|
10
|
+
};
|
11
|
+
|
12
|
+
jasmine.EnvjsReporter.prototype.reportRunnerStarting = function(runner) {
|
13
|
+
this.started = true;
|
14
|
+
var suites = runner.suites();
|
15
|
+
for (var i = 0; i < suites.length; i++) {
|
16
|
+
var suite = suites[i];
|
17
|
+
this.suites_.push(this.summarize_(suite));
|
18
|
+
}
|
19
|
+
this.startedAt = new Date();
|
20
|
+
};
|
21
|
+
|
22
|
+
jasmine.EnvjsReporter.prototype.suites = function() {
|
23
|
+
return this.suites_;
|
24
|
+
};
|
25
|
+
|
26
|
+
jasmine.EnvjsReporter.prototype.summarize_ = function(suiteOrSpec) {
|
27
|
+
var isSuite = suiteOrSpec instanceof jasmine.Suite
|
28
|
+
var summary = {
|
29
|
+
id: suiteOrSpec.id,
|
30
|
+
name: suiteOrSpec.description,
|
31
|
+
type: isSuite ? 'suite' : 'spec',
|
32
|
+
children: []
|
33
|
+
};
|
34
|
+
if (isSuite) {
|
35
|
+
var specs = suiteOrSpec.specs();
|
36
|
+
for (var i = 0; i < specs.length; i++) {
|
37
|
+
summary.children.push(this.summarize_(specs[i]));
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return summary;
|
41
|
+
};
|
42
|
+
|
43
|
+
jasmine.EnvjsReporter.prototype.results = function() {
|
44
|
+
return this.results_;
|
45
|
+
};
|
46
|
+
|
47
|
+
jasmine.EnvjsReporter.prototype.resultsForSpec = function(specId) {
|
48
|
+
return this.results_[specId];
|
49
|
+
};
|
50
|
+
|
51
|
+
//noinspection JSUnusedLocalSymbols
|
52
|
+
jasmine.EnvjsReporter.prototype.reportRunnerResults = function(runner) {
|
53
|
+
this.finished = true;
|
54
|
+
var results = runner.results();
|
55
|
+
var specs = runner.specs();
|
56
|
+
var specCount = specs.length;
|
57
|
+
print();
|
58
|
+
var count = 1;
|
59
|
+
var red = "\x1b[31m";
|
60
|
+
var normal = "\x1b[0m";
|
61
|
+
var green = "\x1b[32m";
|
62
|
+
for(var i in this.results_) {
|
63
|
+
var result = this.results_[i];
|
64
|
+
if( result.result == "failed" ) {
|
65
|
+
var messages = result.messages;
|
66
|
+
for(var j in messages) {
|
67
|
+
var expectation = messages[j];
|
68
|
+
if( !expectation.passed() ) {
|
69
|
+
print();
|
70
|
+
print(count++ + ")");
|
71
|
+
print(red+result.spec.description+normal);
|
72
|
+
var message;
|
73
|
+
message = expectation.message.replace(/(<br \/>)+/g, " ");
|
74
|
+
print(red+message+normal);
|
75
|
+
print_exception(expectation.trace);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
var message = "\nFinished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
81
|
+
print(message);
|
82
|
+
message = "\n" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
83
|
+
if(results.failedCount > 0){
|
84
|
+
message = red + message;
|
85
|
+
} else {
|
86
|
+
message = green + message;
|
87
|
+
}
|
88
|
+
print(message+normal);
|
89
|
+
};
|
90
|
+
|
91
|
+
//noinspection JSUnusedLocalSymbols
|
92
|
+
jasmine.EnvjsReporter.prototype.reportSuiteResults = function(suite) {
|
93
|
+
};
|
94
|
+
|
95
|
+
//noinspection JSUnusedLocalSymbols
|
96
|
+
jasmine.EnvjsReporter.prototype.reportSpecResults = function(spec) {
|
97
|
+
puts(spec.results().failedCount > 0 ? "\x1b[31mF\x1b[0m" : "\x1b[32m.\x1b[0m");
|
98
|
+
this.results_[spec.id] = {
|
99
|
+
spec: spec,
|
100
|
+
messages: spec.results().getItems(),
|
101
|
+
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
102
|
+
};
|
103
|
+
};
|
104
|
+
|
105
|
+
//noinspection JSUnusedLocalSymbols
|
106
|
+
jasmine.EnvjsReporter.prototype.log = function(str) {
|
107
|
+
// print(str);
|
108
|
+
};
|
109
|
+
|
110
|
+
jasmine.EnvjsReporter.prototype.resultsForSpecs = function(specIds){
|
111
|
+
var results = {};
|
112
|
+
for (var i = 0; i < specIds.length; i++) {
|
113
|
+
var specId = specIds[i];
|
114
|
+
results[specId] = this.summarizeResult_(this.results_[specId]);
|
115
|
+
}
|
116
|
+
return results;
|
117
|
+
};
|
118
|
+
|
119
|
+
jasmine.EnvjsReporter.prototype.summarizeResult_ = function(result){
|
120
|
+
var summaryMessages = [];
|
121
|
+
for (var messageIndex in result.messages) {
|
122
|
+
var resultMessage = result.messages[messageIndex];
|
123
|
+
summaryMessages.push({
|
124
|
+
text: resultMessage.text,
|
125
|
+
passed: resultMessage.passed ? resultMessage.passed() : true,
|
126
|
+
type: resultMessage.type,
|
127
|
+
message: resultMessage.message,
|
128
|
+
trace: {
|
129
|
+
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined
|
130
|
+
}
|
131
|
+
});
|
132
|
+
};
|
133
|
+
|
134
|
+
var summaryResult = {
|
135
|
+
result : result.result,
|
136
|
+
messages : summaryMessages
|
137
|
+
};
|
138
|
+
|
139
|
+
return summaryResult;
|
140
|
+
};
|
141
|
+
|
@@ -0,0 +1,155 @@
|
|
1
|
+
jasmine.TrivialReporter = function(doc) {
|
2
|
+
this.document = doc || document;
|
3
|
+
this.suiteDivs = {};
|
4
|
+
};
|
5
|
+
|
6
|
+
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
7
|
+
var el = document.createElement(type);
|
8
|
+
|
9
|
+
for (var i = 2; i < arguments.length; i++) {
|
10
|
+
var child = arguments[i];
|
11
|
+
|
12
|
+
if (typeof child === 'string') {
|
13
|
+
el.appendChild(document.createTextNode(child));
|
14
|
+
} else {
|
15
|
+
if (child) { el.appendChild(child); }
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
for (var attr in attrs) {
|
20
|
+
el[attr] = attrs[attr];
|
21
|
+
}
|
22
|
+
|
23
|
+
return el;
|
24
|
+
};
|
25
|
+
|
26
|
+
jasmine.TrivialReporter.prototype._argString = function(s) {
|
27
|
+
// Maintain non-"spec" arguments
|
28
|
+
var undefined;
|
29
|
+
|
30
|
+
if(this.specs == undefined){
|
31
|
+
this.specs = "?";
|
32
|
+
var args = window.location.href;
|
33
|
+
args = args.split('?');
|
34
|
+
if(args.length>1){
|
35
|
+
args = args[1].split("&");
|
36
|
+
var map = {};
|
37
|
+
for(var i=0; i<args.length; i++){
|
38
|
+
var pair = args[i].split("=");
|
39
|
+
if (pair[0]!="spec"){
|
40
|
+
map[pair[0]] = pair[1];
|
41
|
+
}
|
42
|
+
}
|
43
|
+
for(var key in map){
|
44
|
+
if(this.specs!="?"){
|
45
|
+
this.specs = specs+"&";
|
46
|
+
}
|
47
|
+
this.specs = this.specs + key + "=" + map[key];
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
var spec = this.specs;
|
53
|
+
|
54
|
+
if(s) {
|
55
|
+
if(spec!="?"){
|
56
|
+
spec = spec + "&";
|
57
|
+
}
|
58
|
+
spec = spec + "spec=" + encodeURIComponent(s); //
|
59
|
+
}
|
60
|
+
|
61
|
+
return spec;
|
62
|
+
};
|
63
|
+
|
64
|
+
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
65
|
+
var suites = runner.suites();
|
66
|
+
|
67
|
+
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
68
|
+
this.createDom('a', { className: 'run_spec', href: this._argString() }, "run all"),
|
69
|
+
this.runnerMessageSpan = this.createDom('span', {}, "Running..."));
|
70
|
+
this.document.body.appendChild(this.runnerDiv);
|
71
|
+
|
72
|
+
for (var i = 0; i < suites.length; i++) {
|
73
|
+
var suite = suites[i];
|
74
|
+
var suiteDiv = this.createDom('div', { className: 'suite' },
|
75
|
+
this.createDom('a', { className: 'run_spec', href: this._argString(suite.getFullName()) }, "run"),
|
76
|
+
this.createDom('a', { className: 'description', href: this._argString(suite.getFullName()) }, suite.description));
|
77
|
+
this.suiteDivs[suite.getFullName()] = suiteDiv;
|
78
|
+
var parentDiv = this.document.body;
|
79
|
+
if (suite.parentSuite) {
|
80
|
+
parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
|
81
|
+
}
|
82
|
+
parentDiv.appendChild(suiteDiv);
|
83
|
+
}
|
84
|
+
|
85
|
+
this.startedAt = new Date();
|
86
|
+
};
|
87
|
+
|
88
|
+
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
89
|
+
var results = runner.results();
|
90
|
+
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
91
|
+
this.runnerDiv.setAttribute("class", className);
|
92
|
+
//do it twice for IE
|
93
|
+
this.runnerDiv.setAttribute("className", className);
|
94
|
+
var specs = runner.specs();
|
95
|
+
var specCount = 0;
|
96
|
+
for (var i = 0; i < specs.length; i++) {
|
97
|
+
if (this.specFilter(specs[i])) {
|
98
|
+
specCount++;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
102
|
+
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
103
|
+
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: this._argString()}, message), this.runnerMessageSpan.firstChild);
|
104
|
+
};
|
105
|
+
|
106
|
+
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
107
|
+
var results = suite.results();
|
108
|
+
var status = results.passed() ? 'passed' : 'failed';
|
109
|
+
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
110
|
+
status = 'skipped';
|
111
|
+
}
|
112
|
+
this.suiteDivs[suite.getFullName()].className += " " + status;
|
113
|
+
};
|
114
|
+
|
115
|
+
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
116
|
+
var results = spec.results();
|
117
|
+
var status = results.passed() ? 'passed' : 'failed';
|
118
|
+
if (results.skipped) {
|
119
|
+
status = 'skipped';
|
120
|
+
}
|
121
|
+
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
122
|
+
this.createDom('a', { className: 'run_spec', href: this._argString(encodeURIComponent(spec.getFullName())) }, "run"),
|
123
|
+
this.createDom('a', { className: 'description', href: this._argString(encodeURIComponent(spec.getFullName())) }, spec.getFullName()));
|
124
|
+
|
125
|
+
|
126
|
+
var resultItems = results.getItems();
|
127
|
+
for (var i = 0; i < resultItems.length; i++) {
|
128
|
+
var result = resultItems[i];
|
129
|
+
if (result.passed && !result.passed()) {
|
130
|
+
specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
131
|
+
specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
132
|
+
}
|
133
|
+
}
|
134
|
+
this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
|
135
|
+
};
|
136
|
+
|
137
|
+
jasmine.TrivialReporter.prototype.log = function() {
|
138
|
+
this.console && console.log.apply(console, arguments);
|
139
|
+
};
|
140
|
+
|
141
|
+
jasmine.TrivialReporter.prototype.getLocation = function() {
|
142
|
+
return this.document.location;
|
143
|
+
};
|
144
|
+
|
145
|
+
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
146
|
+
var paramMap = {};
|
147
|
+
var params = this.getLocation().search.substring(1).split('&');
|
148
|
+
for (var i = 0; i < params.length; i++) {
|
149
|
+
var p = params[i].split('=');
|
150
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
151
|
+
}
|
152
|
+
|
153
|
+
if (!paramMap["spec"]) return true;
|
154
|
+
return spec.getFullName().indexOf(decodeURIComponent(paramMap["spec"])) == 0;
|
155
|
+
};
|
@@ -0,0 +1,241 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
var APOS = "'"; QUOTE = '"';
|
4
|
+
var ESCAPED_QUOTE = { };
|
5
|
+
ESCAPED_QUOTE[QUOTE] = '"';
|
6
|
+
ESCAPED_QUOTE[APOS] = ''';
|
7
|
+
|
8
|
+
function formatAttributes(attributes) {
|
9
|
+
var att_value;
|
10
|
+
var apos_pos, quot_pos;
|
11
|
+
var use_quote, escape, quote_to_escape;
|
12
|
+
var att_str;
|
13
|
+
var re;
|
14
|
+
var result = '';
|
15
|
+
|
16
|
+
for (var att in attributes) {
|
17
|
+
att_value = attributes[att] || "";
|
18
|
+
|
19
|
+
att_value = att_value.replace(/&/g, "&");
|
20
|
+
att_value = att_value.replace(/</g, "<");
|
21
|
+
att_value = att_value.replace(/>/g, ">");
|
22
|
+
|
23
|
+
// Find first quote marks if any
|
24
|
+
apos_pos = att_value.indexOf(APOS);
|
25
|
+
quot_pos = att_value.indexOf(QUOTE);
|
26
|
+
|
27
|
+
// Determine which quote type to use around
|
28
|
+
// the attribute value
|
29
|
+
if (apos_pos == -1 && quot_pos == -1) {
|
30
|
+
att_str = ' ' + att + "='" + att_value + "'";
|
31
|
+
result += att_str;
|
32
|
+
continue;
|
33
|
+
}
|
34
|
+
|
35
|
+
// Prefer the single quote unless forced to use double
|
36
|
+
if (quot_pos != -1 && quot_pos < apos_pos) {
|
37
|
+
use_quote = APOS;
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
use_quote = QUOTE;
|
41
|
+
}
|
42
|
+
|
43
|
+
// Figure out which kind of quote to escape
|
44
|
+
// Use nice dictionary instead of yucky if-else nests
|
45
|
+
escape = ESCAPED_QUOTE[use_quote];
|
46
|
+
|
47
|
+
// Escape only the right kind of quote
|
48
|
+
re = new RegExp(use_quote,'g');
|
49
|
+
att_str = ' ' + att + '=' + use_quote +
|
50
|
+
att_value.replace(re, escape) + use_quote;
|
51
|
+
result += att_str;
|
52
|
+
}
|
53
|
+
return result;
|
54
|
+
};
|
55
|
+
|
56
|
+
|
57
|
+
/** JavaScript API reporter.
|
58
|
+
*
|
59
|
+
* @constructor
|
60
|
+
*/
|
61
|
+
jasmine.XMLReporter = function() {
|
62
|
+
this.started = false;
|
63
|
+
this.finished = false;
|
64
|
+
this.suites_ = [];
|
65
|
+
this.results_ = {};
|
66
|
+
};
|
67
|
+
|
68
|
+
jasmine.XMLReporter.prototype.reportRunnerStarting = function(runner) {
|
69
|
+
this.started = true;
|
70
|
+
var suites = runner.suites();
|
71
|
+
for (var i = 0; i < suites.length; i++) {
|
72
|
+
var suite = suites[i];
|
73
|
+
this.suites_.push(this.summarize_(suite));
|
74
|
+
}
|
75
|
+
this.startedAt = new Date();
|
76
|
+
puts("<testsuites>")
|
77
|
+
};
|
78
|
+
|
79
|
+
jasmine.XMLReporter.prototype.suites = function() {
|
80
|
+
return this.suites_;
|
81
|
+
};
|
82
|
+
|
83
|
+
jasmine.XMLReporter.prototype.summarize_ = function(suiteOrSpec) {
|
84
|
+
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
85
|
+
var summary = {
|
86
|
+
id: suiteOrSpec.id,
|
87
|
+
name: suiteOrSpec.description,
|
88
|
+
type: isSuite ? 'suite' : 'spec',
|
89
|
+
children: []
|
90
|
+
};
|
91
|
+
if (isSuite) {
|
92
|
+
var specs = suiteOrSpec.specs();
|
93
|
+
for (var i = 0; i < specs.length; i++) {
|
94
|
+
summary.children.push(this.summarize_(specs[i]));
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return summary;
|
98
|
+
};
|
99
|
+
|
100
|
+
jasmine.XMLReporter.prototype.results = function() {
|
101
|
+
return this.results_;
|
102
|
+
};
|
103
|
+
|
104
|
+
jasmine.XMLReporter.prototype.resultsForSpec = function(specId) {
|
105
|
+
return this.results_[specId];
|
106
|
+
};
|
107
|
+
|
108
|
+
//noinspection JSUnusedLocalSymbols
|
109
|
+
jasmine.XMLReporter.prototype.reportRunnerResults = function(runner) {
|
110
|
+
this.finished = true;
|
111
|
+
var results = runner.results();
|
112
|
+
var specs = runner.specs();
|
113
|
+
var specCount = specs.length;
|
114
|
+
if(jasmine.XMLReporter.current_spec){
|
115
|
+
puts(" </testsuite>");
|
116
|
+
}
|
117
|
+
// puts(" <tests>"+specCount+"</tests>");
|
118
|
+
// puts(" <errors>"+results.failedCount+"</errors>");
|
119
|
+
// puts(" <skipped>0</skipped>");
|
120
|
+
// puts(" <failures>0</failures>");
|
121
|
+
// puts(" <time>"+((new Date().getTime() - this.startedAt.getTime()) / 1000)+"</time>");
|
122
|
+
puts("</testsuites>");
|
123
|
+
};
|
124
|
+
|
125
|
+
//noinspection JSUnusedLocalSymbols
|
126
|
+
jasmine.XMLReporter.prototype.reportSuiteResults = function(suite) {
|
127
|
+
};
|
128
|
+
|
129
|
+
//noinspection JSUnusedLocalSymbols
|
130
|
+
jasmine.XMLReporter.prototype.reportSpecResults = function(spec) {
|
131
|
+
var suite = spec.suite;
|
132
|
+
if(jasmine.XMLReporter.current_spec){
|
133
|
+
puts(" </testsuite>");
|
134
|
+
}
|
135
|
+
var name = [ spec.description ];
|
136
|
+
while(suite){
|
137
|
+
name.unshift( suite.description );
|
138
|
+
suite = suite.parentSuite;
|
139
|
+
}
|
140
|
+
var attrs = {name:name.join(" : ")};
|
141
|
+
if(spec.pending) {
|
142
|
+
attrs.skipped = "true";
|
143
|
+
}
|
144
|
+
puts(" <testsuite"+formatAttributes(attrs) +">");
|
145
|
+
jasmine.XMLReporter.current_spec = spec;
|
146
|
+
this.results_[spec.id] = {
|
147
|
+
spec: spec,
|
148
|
+
messages: spec.results().getItems(),
|
149
|
+
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
150
|
+
};
|
151
|
+
var results = spec.results().getItems();
|
152
|
+
for(var i in results) {
|
153
|
+
var result = results[i];
|
154
|
+
var attrs = {name:(1+parseInt(i))+ ": " + result.matcherName};
|
155
|
+
puts(" <testcase"+formatAttributes(attrs)+">");
|
156
|
+
if(!result.passed() && !attrs.skipped){
|
157
|
+
puts(" <failure"+formatAttributes({type:result.matcherName,
|
158
|
+
message:result.message})+">");
|
159
|
+
puts("<![CDATA[");
|
160
|
+
puts(get_exception_trace(result.trace));
|
161
|
+
puts("]]>");
|
162
|
+
puts(" </failure>");
|
163
|
+
}
|
164
|
+
puts(" </testcase>");
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
168
|
+
//noinspection JSUnusedLocalSymbols
|
169
|
+
jasmine.XMLReporter.prototype._reportSpecResults = function(spec) {
|
170
|
+
var suite = spec.suite;
|
171
|
+
if(jasmine.XMLReporter.current_suite != suite){
|
172
|
+
if(jasmine.XMLReporter.current_suite){
|
173
|
+
puts(" </testsuite>");
|
174
|
+
}
|
175
|
+
var name = [ spec.description ];
|
176
|
+
while(suite){
|
177
|
+
name.unshift( suite.description );
|
178
|
+
suite = suite.parentSuite;
|
179
|
+
}
|
180
|
+
puts(" <testsuite"+formatAttributes({name:name.join(" : ")}) +">");
|
181
|
+
jasmine.XMLReporter.current_suite = spec.suite;
|
182
|
+
}
|
183
|
+
this.results_[spec.id] = {
|
184
|
+
spec: spec,
|
185
|
+
messages: spec.results().getItems(),
|
186
|
+
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
187
|
+
};
|
188
|
+
var results = spec.results().getItems();
|
189
|
+
for(var i in results) {
|
190
|
+
var result = results[i];
|
191
|
+
puts(" <testcase"+formatAttributes({name:(1+parseInt(i))+ ": " + result.matcherName})+">");
|
192
|
+
if(!result.passed()){
|
193
|
+
puts(" <failure"+formatAttributes({type:result.matcherName,
|
194
|
+
message:result.message})+">");
|
195
|
+
puts("<![CDATA[");
|
196
|
+
puts(get_exception_trace(result.trace));
|
197
|
+
puts("]]>");
|
198
|
+
puts(" </failure>");
|
199
|
+
}
|
200
|
+
puts(" </testcase>");
|
201
|
+
}
|
202
|
+
};
|
203
|
+
|
204
|
+
//noinspection JSUnusedLocalSymbols
|
205
|
+
jasmine.XMLReporter.prototype.log = function(str) {
|
206
|
+
// print(str);
|
207
|
+
};
|
208
|
+
|
209
|
+
jasmine.XMLReporter.prototype.resultsForSpecs = function(specIds){
|
210
|
+
var results = {};
|
211
|
+
for (var i = 0; i < specIds.length; i++) {
|
212
|
+
var specId = specIds[i];
|
213
|
+
results[specId] = this.summarizeResult_(this.results_[specId]);
|
214
|
+
}
|
215
|
+
return results;
|
216
|
+
};
|
217
|
+
|
218
|
+
jasmine.XMLReporter.prototype.summarizeResult_ = function(result){
|
219
|
+
var summaryMessages = [];
|
220
|
+
for (var messageIndex in result.messages) {
|
221
|
+
var resultMessage = result.messages[messageIndex];
|
222
|
+
summaryMessages.push({
|
223
|
+
text: resultMessage.text,
|
224
|
+
passed: resultMessage.passed ? resultMessage.passed() : true,
|
225
|
+
type: resultMessage.type,
|
226
|
+
message: resultMessage.message,
|
227
|
+
trace: {
|
228
|
+
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined
|
229
|
+
}
|
230
|
+
});
|
231
|
+
};
|
232
|
+
|
233
|
+
var summaryResult = {
|
234
|
+
result : result.result,
|
235
|
+
messages : summaryMessages
|
236
|
+
};
|
237
|
+
|
238
|
+
return summaryResult;
|
239
|
+
};
|
240
|
+
|
241
|
+
})();
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/** Console X
|
2
|
+
* http://github.com/deadlyicon/consolex.js
|
3
|
+
*
|
4
|
+
* By Jared Grippe <jared@jaredgrippe.com>
|
5
|
+
*
|
6
|
+
* Copyright (c) 2009 Jared Grippe
|
7
|
+
* Licensed under the MIT license.
|
8
|
+
*
|
9
|
+
* consolex avoids ever having to see javascript bugs in browsers that do not implement the entire
|
10
|
+
* firebug console suit
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
(function(window) {
|
14
|
+
window.console || (window.console = {});
|
15
|
+
|
16
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
17
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
18
|
+
|
19
|
+
function emptyFunction(){}
|
20
|
+
|
21
|
+
for (var i = 0; i < names.length; ++i){
|
22
|
+
window.console[names[i]] || (window.console[names[i]] = emptyFunction);
|
23
|
+
if (typeof window.console[names[i]] !== 'function')
|
24
|
+
window.console[names[i]] = (function(method) {
|
25
|
+
return function(){ return Function.prototype.apply.apply(method, [console,arguments]); };
|
26
|
+
})(window.console[names[i]]);
|
27
|
+
}
|
28
|
+
})(this);
|