jasnode 0.2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.gitmodules +3 -0
- data/MIT.LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +34 -0
- data/VERSION.yml +5 -0
- data/bin/jasnode +52 -0
- data/features/jasnode.feature +24 -0
- data/features/step_definitions/jasnode-steps.rb +39 -0
- data/jasmine/MIT.LICENSE +20 -0
- data/jasmine/README.markdown +502 -0
- data/jasmine/Rakefile +158 -0
- data/jasmine/cruise_config.rb +21 -0
- data/jasmine/doc/files.html +460 -0
- data/jasmine/doc/index.html +322 -0
- data/jasmine/doc/symbols/_global_.html +918 -0
- data/jasmine/doc/symbols/jasmine.Block.html +417 -0
- data/jasmine/doc/symbols/jasmine.Clock.html +678 -0
- data/jasmine/doc/symbols/jasmine.Env.html +1169 -0
- data/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
- data/jasmine/doc/symbols/jasmine.Matchers.html +1474 -0
- data/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
- data/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
- data/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
- data/jasmine/doc/symbols/jasmine.Runner.html +710 -0
- data/jasmine/doc/symbols/jasmine.Spec.html +1253 -0
- data/jasmine/doc/symbols/jasmine.Spy.html +855 -0
- data/jasmine/doc/symbols/jasmine.Suite.html +705 -0
- data/jasmine/doc/symbols/jasmine.html +1345 -0
- data/jasmine/doc/symbols/jasmine.util.html +535 -0
- data/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +124 -0
- data/jasmine/doc/symbols/src/src_Block.js.html +29 -0
- data/jasmine/doc/symbols/src/src_Env.js.html +248 -0
- data/jasmine/doc/symbols/src/src_JsApiReporter.js.html +111 -0
- data/jasmine/doc/symbols/src/src_Matchers.js.html +344 -0
- data/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
- data/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
- data/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +130 -0
- data/jasmine/doc/symbols/src/src_Queue.js.html +102 -0
- data/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
- data/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
- data/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
- data/jasmine/doc/symbols/src/src_Spec.js.html +214 -0
- data/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
- data/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
- data/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
- data/jasmine/doc/symbols/src/src_base.js.html +585 -0
- data/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
- data/jasmine/doc/symbols/src/src_util.js.html +75 -0
- data/jasmine/examples/html/example_runner.html +27 -0
- data/jasmine/examples/html/spec/example_suite.js +11 -0
- data/jasmine/examples/ruby/Rakefile +33 -0
- data/jasmine/examples/ruby/spec/example/example_spec.js +11 -0
- data/jasmine/examples/ruby/spec/jasmine_helper.rb +41 -0
- data/jasmine/examples/ruby/spec/jasmine_spec.rb +31 -0
- data/jasmine/examples/ruby/spec/saucelabs.yml +24 -0
- data/jasmine/geminstaller.yml +25 -0
- data/jasmine/images/fail-16.png +0 -0
- data/jasmine/images/fail.png +0 -0
- data/jasmine/images/go-16.png +0 -0
- data/jasmine/images/go.png +0 -0
- data/jasmine/images/pending-16.png +0 -0
- data/jasmine/images/pending.png +0 -0
- data/jasmine/images/question-bk.png +0 -0
- data/jasmine/images/questionbk-16.png +0 -0
- data/jasmine/images/spinner.gif +0 -0
- data/jasmine/lib/TrivialReporter.js +117 -0
- data/jasmine/lib/consolex.js +28 -0
- data/jasmine/lib/jasmine-0.10.2.js +2318 -0
- data/jasmine/lib/jasmine.css +86 -0
- data/jasmine/lib/json2.js +478 -0
- data/jasmine/spec/jasmine_helper.rb +44 -0
- data/jasmine/spec/jasmine_spec.rb +31 -0
- data/jasmine/spec/runner.html +79 -0
- data/jasmine/spec/saucelabs.yml +24 -0
- data/jasmine/spec/suites/CustomMatchersSpec.js +112 -0
- data/jasmine/spec/suites/EnvSpec.js +141 -0
- data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
- data/jasmine/spec/suites/JsApiReporterSpec.js +82 -0
- data/jasmine/spec/suites/MatchersSpec.js +709 -0
- data/jasmine/spec/suites/MockClockSpec.js +34 -0
- data/jasmine/spec/suites/MultiReporterSpec.js +30 -0
- data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
- data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
- data/jasmine/spec/suites/QueueSpec.js +23 -0
- data/jasmine/spec/suites/ReporterSpec.js +60 -0
- data/jasmine/spec/suites/RunnerSpec.js +252 -0
- data/jasmine/spec/suites/SpecRunningSpec.js +1086 -0
- data/jasmine/spec/suites/SpecSpec.js +110 -0
- data/jasmine/spec/suites/SpySpec.js +201 -0
- data/jasmine/spec/suites/SuiteSpec.js +101 -0
- data/jasmine/spec/suites/TrivialReporterSpec.js +140 -0
- data/jasmine/spec/suites/UtilSpec.js +40 -0
- data/jasmine/src/Block.js +22 -0
- data/jasmine/src/Env.js +240 -0
- data/jasmine/src/JsApiReporter.js +103 -0
- data/jasmine/src/Matchers.js +336 -0
- data/jasmine/src/MultiReporter.js +28 -0
- data/jasmine/src/NestedResults.js +80 -0
- data/jasmine/src/PrettyPrinter.js +122 -0
- data/jasmine/src/Queue.js +94 -0
- data/jasmine/src/Reporter.js +27 -0
- data/jasmine/src/Reporters.js +43 -0
- data/jasmine/src/Runner.js +68 -0
- data/jasmine/src/Spec.js +206 -0
- data/jasmine/src/Suite.js +70 -0
- data/jasmine/src/WaitsBlock.js +13 -0
- data/jasmine/src/WaitsForBlock.js +38 -0
- data/jasmine/src/base.js +578 -0
- data/jasmine/src/mock-timeout.js +177 -0
- data/jasmine/src/util.js +67 -0
- data/jasmine/src/version.json +5 -0
- data/jasnode.gemspec +171 -0
- data/lib/jasnode/core.rb +180 -0
- data/lib/jasnode.js +135 -0
- data/lib/jasnode.rb +4 -0
- data/pkg/jasnode-0.1.0.0.gem +0 -0
- data/spec/jasnode/jasnode_spec.rb +40 -0
- data/spec/rspec_suite.rb +8 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/Rakefile +9 -0
- data/templates/bin/hello_world +5 -0
- data/templates/lib/server.js +25 -0
- data/templates/spec/README.md +3 -0
- data/templates/spec/runner.js +16 -0
- data/templates/spec/server/server_spec.js +45 -0
- data/templates/spec/server/spec_server.js +45 -0
- data/templates/spec/spec.js +45 -0
- metadata +184 -0
data/jasmine/src/Env.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment for Jasmine
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*/
|
|
6
|
+
jasmine.Env = function() {
|
|
7
|
+
this.currentSpec = null;
|
|
8
|
+
this.currentSuite = null;
|
|
9
|
+
this.currentRunner_ = new jasmine.Runner(this);
|
|
10
|
+
|
|
11
|
+
this.reporter = new jasmine.MultiReporter();
|
|
12
|
+
|
|
13
|
+
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
|
14
|
+
this.lastUpdate = 0;
|
|
15
|
+
this.specFilter = function() {
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.nextSpecId_ = 0;
|
|
20
|
+
this.nextSuiteId_ = 0;
|
|
21
|
+
this.equalityTesters_ = [];
|
|
22
|
+
|
|
23
|
+
// wrap matchers
|
|
24
|
+
this.matchersClass = function() {
|
|
25
|
+
jasmine.Matchers.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
|
|
28
|
+
|
|
29
|
+
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
|
|
34
|
+
jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
|
35
|
+
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
|
36
|
+
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @returns an object containing jasmine version build info, if set.
|
|
40
|
+
*/
|
|
41
|
+
jasmine.Env.prototype.version = function () {
|
|
42
|
+
if (jasmine.version_) {
|
|
43
|
+
return jasmine.version_;
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error('Version not set');
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @returns a sequential integer starting at 0
|
|
51
|
+
*/
|
|
52
|
+
jasmine.Env.prototype.nextSpecId = function () {
|
|
53
|
+
return this.nextSpecId_++;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @returns a sequential integer starting at 0
|
|
58
|
+
*/
|
|
59
|
+
jasmine.Env.prototype.nextSuiteId = function () {
|
|
60
|
+
return this.nextSuiteId_++;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Register a reporter to receive status updates from Jasmine.
|
|
65
|
+
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
|
66
|
+
*/
|
|
67
|
+
jasmine.Env.prototype.addReporter = function(reporter) {
|
|
68
|
+
this.reporter.addReporter(reporter);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
jasmine.Env.prototype.execute = function() {
|
|
72
|
+
this.currentRunner_.execute();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
|
76
|
+
var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
|
|
77
|
+
|
|
78
|
+
var parentSuite = this.currentSuite;
|
|
79
|
+
if (parentSuite) {
|
|
80
|
+
parentSuite.add(suite);
|
|
81
|
+
} else {
|
|
82
|
+
this.currentRunner_.add(suite);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.currentSuite = suite;
|
|
86
|
+
|
|
87
|
+
specDefinitions.call(suite);
|
|
88
|
+
|
|
89
|
+
this.currentSuite = parentSuite;
|
|
90
|
+
|
|
91
|
+
return suite;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
|
|
95
|
+
if (this.currentSuite) {
|
|
96
|
+
this.currentSuite.beforeEach(beforeEachFunction);
|
|
97
|
+
} else {
|
|
98
|
+
this.currentRunner_.beforeEach(beforeEachFunction);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
jasmine.Env.prototype.currentRunner = function () {
|
|
103
|
+
return this.currentRunner_;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
jasmine.Env.prototype.afterEach = function(afterEachFunction) {
|
|
107
|
+
if (this.currentSuite) {
|
|
108
|
+
this.currentSuite.afterEach(afterEachFunction);
|
|
109
|
+
} else {
|
|
110
|
+
this.currentRunner_.afterEach(afterEachFunction);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
|
116
|
+
return {
|
|
117
|
+
execute: function() {
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
jasmine.Env.prototype.it = function(description, func) {
|
|
123
|
+
var spec = new jasmine.Spec(this, this.currentSuite, description);
|
|
124
|
+
this.currentSuite.add(spec);
|
|
125
|
+
this.currentSpec = spec;
|
|
126
|
+
|
|
127
|
+
if (func) {
|
|
128
|
+
spec.runs(func);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return spec;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
jasmine.Env.prototype.xit = function(desc, func) {
|
|
135
|
+
return {
|
|
136
|
+
id: this.nextSpecId(),
|
|
137
|
+
runs: function() {
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
|
|
143
|
+
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
a.__Jasmine_been_here_before__ = b;
|
|
148
|
+
b.__Jasmine_been_here_before__ = a;
|
|
149
|
+
|
|
150
|
+
var hasKey = function(obj, keyName) {
|
|
151
|
+
return obj != null && obj[keyName] !== jasmine.undefined;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
for (var property in b) {
|
|
155
|
+
if (!hasKey(a, property) && hasKey(b, property)) {
|
|
156
|
+
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (property in a) {
|
|
160
|
+
if (!hasKey(b, property) && hasKey(a, property)) {
|
|
161
|
+
mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (property in b) {
|
|
165
|
+
if (property == '__Jasmine_been_here_before__') continue;
|
|
166
|
+
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
|
|
167
|
+
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
|
|
172
|
+
mismatchValues.push("arrays were not the same length");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
delete a.__Jasmine_been_here_before__;
|
|
176
|
+
delete b.__Jasmine_been_here_before__;
|
|
177
|
+
return (mismatchKeys.length == 0 && mismatchValues.length == 0);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
|
181
|
+
mismatchKeys = mismatchKeys || [];
|
|
182
|
+
mismatchValues = mismatchValues || [];
|
|
183
|
+
|
|
184
|
+
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
|
185
|
+
var equalityTester = this.equalityTesters_[i];
|
|
186
|
+
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
|
187
|
+
if (result !== jasmine.undefined) return result;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (a === b) return true;
|
|
191
|
+
|
|
192
|
+
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
|
193
|
+
return (a == jasmine.undefined && b == jasmine.undefined);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
|
197
|
+
return a === b;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (a instanceof Date && b instanceof Date) {
|
|
201
|
+
return a.getTime() == b.getTime();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (a instanceof jasmine.Matchers.Any) {
|
|
205
|
+
return a.matches(b);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (b instanceof jasmine.Matchers.Any) {
|
|
209
|
+
return b.matches(a);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (jasmine.isString_(a) && jasmine.isString_(b)) {
|
|
213
|
+
return (a == b);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
|
217
|
+
return (a == b);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
221
|
+
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
//Straight check
|
|
225
|
+
return (a === b);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
jasmine.Env.prototype.contains_ = function(haystack, needle) {
|
|
229
|
+
if (jasmine.isArray_(haystack)) {
|
|
230
|
+
for (var i = 0; i < haystack.length; i++) {
|
|
231
|
+
if (this.equals_(haystack[i], needle)) return true;
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
return haystack.indexOf(needle) >= 0;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
|
|
239
|
+
this.equalityTesters_.push(equalityTester);
|
|
240
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** JavaScript API reporter.
|
|
2
|
+
*
|
|
3
|
+
* @constructor
|
|
4
|
+
*/
|
|
5
|
+
jasmine.JsApiReporter = function() {
|
|
6
|
+
this.started = false;
|
|
7
|
+
this.finished = false;
|
|
8
|
+
this.suites_ = [];
|
|
9
|
+
this.results_ = {};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
jasmine.JsApiReporter.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
|
+
};
|
|
20
|
+
|
|
21
|
+
jasmine.JsApiReporter.prototype.suites = function() {
|
|
22
|
+
return this.suites_;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
|
26
|
+
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
|
27
|
+
var summary = {
|
|
28
|
+
id: suiteOrSpec.id,
|
|
29
|
+
name: suiteOrSpec.description,
|
|
30
|
+
type: isSuite ? 'suite' : 'spec',
|
|
31
|
+
children: []
|
|
32
|
+
};
|
|
33
|
+
if (isSuite) {
|
|
34
|
+
var specs = suiteOrSpec.specs();
|
|
35
|
+
for (var i = 0; i < specs.length; i++) {
|
|
36
|
+
summary.children.push(this.summarize_(specs[i]));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return summary;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
jasmine.JsApiReporter.prototype.results = function() {
|
|
43
|
+
return this.results_;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
|
|
47
|
+
return this.results_[specId];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//noinspection JSUnusedLocalSymbols
|
|
51
|
+
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
|
|
52
|
+
this.finished = true;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//noinspection JSUnusedLocalSymbols
|
|
56
|
+
jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//noinspection JSUnusedLocalSymbols
|
|
60
|
+
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
|
|
61
|
+
this.results_[spec.id] = {
|
|
62
|
+
messages: spec.results().getItems(),
|
|
63
|
+
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//noinspection JSUnusedLocalSymbols
|
|
68
|
+
jasmine.JsApiReporter.prototype.log = function(str) {
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
|
|
72
|
+
var results = {};
|
|
73
|
+
for (var i = 0; i < specIds.length; i++) {
|
|
74
|
+
var specId = specIds[i];
|
|
75
|
+
results[specId] = this.summarizeResult_(this.results_[specId]);
|
|
76
|
+
}
|
|
77
|
+
return results;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
|
81
|
+
var summaryMessages = [];
|
|
82
|
+
var messagesLength = result.messages.length
|
|
83
|
+
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
|
|
84
|
+
var resultMessage = result.messages[messageIndex];
|
|
85
|
+
summaryMessages.push({
|
|
86
|
+
text: resultMessage.text,
|
|
87
|
+
passed: resultMessage.passed ? resultMessage.passed() : true,
|
|
88
|
+
type: resultMessage.type,
|
|
89
|
+
message: resultMessage.message,
|
|
90
|
+
trace: {
|
|
91
|
+
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var summaryResult = {
|
|
97
|
+
result : result.result,
|
|
98
|
+
messages : summaryMessages
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return summaryResult;
|
|
102
|
+
};
|
|
103
|
+
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @constructor
|
|
3
|
+
* @param {jasmine.Env} env
|
|
4
|
+
* @param actual
|
|
5
|
+
* @param {jasmine.Spec} spec
|
|
6
|
+
*/
|
|
7
|
+
jasmine.Matchers = function(env, actual, spec, opt_isNot) {
|
|
8
|
+
this.env = env;
|
|
9
|
+
this.actual = actual;
|
|
10
|
+
this.spec = spec;
|
|
11
|
+
this.isNot = opt_isNot || false;
|
|
12
|
+
this.reportWasCalled_ = false;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
|
|
16
|
+
jasmine.Matchers.pp = function(str) {
|
|
17
|
+
throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
|
|
18
|
+
this.report();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. */
|
|
22
|
+
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
|
23
|
+
// todo: report a deprecation warning [xw]
|
|
24
|
+
|
|
25
|
+
if (this.isNot) {
|
|
26
|
+
throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.reportWasCalled_ = true;
|
|
30
|
+
var expectationResult = new jasmine.ExpectationResult({
|
|
31
|
+
passed: result,
|
|
32
|
+
message: failing_message,
|
|
33
|
+
details: details
|
|
34
|
+
});
|
|
35
|
+
this.spec.addMatcherResult(expectationResult);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
|
|
40
|
+
for (var methodName in prototype) {
|
|
41
|
+
if (methodName == 'report') continue;
|
|
42
|
+
var orig = prototype[methodName];
|
|
43
|
+
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
|
48
|
+
return function() {
|
|
49
|
+
var matcherArgs = jasmine.util.argsToArray(arguments);
|
|
50
|
+
var result = matcherFunction.apply(this, arguments);
|
|
51
|
+
|
|
52
|
+
if (this.isNot) {
|
|
53
|
+
result = !result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.reportWasCalled_) return result;
|
|
57
|
+
|
|
58
|
+
var message;
|
|
59
|
+
if (!result) {
|
|
60
|
+
if (this.message) {
|
|
61
|
+
message = this.message.apply(this, arguments);
|
|
62
|
+
if (jasmine.isArray_(message)) {
|
|
63
|
+
message = message[this.isNot ? 1 : 0];
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
|
67
|
+
message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
|
|
68
|
+
if (matcherArgs.length > 0) {
|
|
69
|
+
for (var i = 0; i < matcherArgs.length; i++) {
|
|
70
|
+
if (i > 0) message += ",";
|
|
71
|
+
message += " " + jasmine.pp(matcherArgs[i]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
message += ".";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
var expectationResult = new jasmine.ExpectationResult({
|
|
78
|
+
matcherName: matcherName,
|
|
79
|
+
passed: result,
|
|
80
|
+
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
|
|
81
|
+
actual: this.actual,
|
|
82
|
+
message: message
|
|
83
|
+
});
|
|
84
|
+
this.spec.addMatcherResult(expectationResult);
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* toBe: compares the actual to the expected using ===
|
|
94
|
+
* @param expected
|
|
95
|
+
*/
|
|
96
|
+
jasmine.Matchers.prototype.toBe = function(expected) {
|
|
97
|
+
return this.actual === expected;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* toNotBe: compares the actual to the expected using !==
|
|
102
|
+
* @param expected
|
|
103
|
+
*/
|
|
104
|
+
jasmine.Matchers.prototype.toNotBe = function(expected) {
|
|
105
|
+
return this.actual !== expected;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
|
110
|
+
*
|
|
111
|
+
* @param expected
|
|
112
|
+
*/
|
|
113
|
+
jasmine.Matchers.prototype.toEqual = function(expected) {
|
|
114
|
+
return this.env.equals_(this.actual, expected);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
|
119
|
+
* @param expected
|
|
120
|
+
*/
|
|
121
|
+
jasmine.Matchers.prototype.toNotEqual = function(expected) {
|
|
122
|
+
return !this.env.equals_(this.actual, expected);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
|
|
127
|
+
* a pattern or a String.
|
|
128
|
+
*
|
|
129
|
+
* @param expected
|
|
130
|
+
*/
|
|
131
|
+
jasmine.Matchers.prototype.toMatch = function(expected) {
|
|
132
|
+
return new RegExp(expected).test(this.actual);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
|
137
|
+
* @param expected
|
|
138
|
+
*/
|
|
139
|
+
jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
|
140
|
+
return !(new RegExp(expected).test(this.actual));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Matcher that compares the actual to jasmine.undefined.
|
|
145
|
+
*/
|
|
146
|
+
jasmine.Matchers.prototype.toBeDefined = function() {
|
|
147
|
+
return (this.actual !== jasmine.undefined);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Matcher that compares the actual to jasmine.undefined.
|
|
152
|
+
*/
|
|
153
|
+
jasmine.Matchers.prototype.toBeUndefined = function() {
|
|
154
|
+
return (this.actual === jasmine.undefined);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Matcher that compares the actual to null.
|
|
159
|
+
*/
|
|
160
|
+
jasmine.Matchers.prototype.toBeNull = function() {
|
|
161
|
+
return (this.actual === null);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Matcher that boolean not-nots the actual.
|
|
166
|
+
*/
|
|
167
|
+
jasmine.Matchers.prototype.toBeTruthy = function() {
|
|
168
|
+
return !!this.actual;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Matcher that boolean nots the actual.
|
|
174
|
+
*/
|
|
175
|
+
jasmine.Matchers.prototype.toBeFalsy = function() {
|
|
176
|
+
return !this.actual;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Matcher that checks to see if the actual, a Jasmine spy, was called.
|
|
181
|
+
*/
|
|
182
|
+
jasmine.Matchers.prototype.wasCalled = function() {
|
|
183
|
+
if (arguments.length > 0) {
|
|
184
|
+
throw new Error('wasCalled does not take arguments, use wasCalledWith');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (!jasmine.isSpy(this.actual)) {
|
|
188
|
+
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this.message = function() {
|
|
192
|
+
return "Expected spy " + this.actual.identity + " to have been called.";
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return this.actual.wasCalled;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Matcher that checks to see if the actual, a Jasmine spy, was not called.
|
|
200
|
+
*/
|
|
201
|
+
jasmine.Matchers.prototype.wasNotCalled = function() {
|
|
202
|
+
if (arguments.length > 0) {
|
|
203
|
+
throw new Error('wasNotCalled does not take arguments');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (!jasmine.isSpy(this.actual)) {
|
|
207
|
+
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
this.message = function() {
|
|
211
|
+
return "Expected spy " + this.actual.identity + " to not have been called.";
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
return !this.actual.wasCalled;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
*
|
|
222
|
+
*/
|
|
223
|
+
jasmine.Matchers.prototype.wasCalledWith = function() {
|
|
224
|
+
var expectedArgs = jasmine.util.argsToArray(arguments);
|
|
225
|
+
if (!jasmine.isSpy(this.actual)) {
|
|
226
|
+
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
|
227
|
+
}
|
|
228
|
+
this.message = function() {
|
|
229
|
+
if (this.actual.callCount == 0) {
|
|
230
|
+
return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
|
|
231
|
+
} else {
|
|
232
|
+
return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
return this.env.contains_(this.actual.argsForCall, expectedArgs);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
|
240
|
+
var expectedArgs = jasmine.util.argsToArray(arguments);
|
|
241
|
+
if (!jasmine.isSpy(this.actual)) {
|
|
242
|
+
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
this.message = function() {
|
|
246
|
+
return "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was";
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Matcher that checks that the expected item is an element in the actual Array.
|
|
254
|
+
*
|
|
255
|
+
* @param {Object} expected
|
|
256
|
+
*/
|
|
257
|
+
jasmine.Matchers.prototype.toContain = function(expected) {
|
|
258
|
+
return this.env.contains_(this.actual, expected);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
|
263
|
+
*
|
|
264
|
+
* @param {Object} expected
|
|
265
|
+
*/
|
|
266
|
+
jasmine.Matchers.prototype.toNotContain = function(expected) {
|
|
267
|
+
return !this.env.contains_(this.actual, expected);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
jasmine.Matchers.prototype.toBeLessThan = function(expected) {
|
|
271
|
+
return this.actual < expected;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
|
275
|
+
return this.actual > expected;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Matcher that checks that the expected exception was thrown by the actual.
|
|
280
|
+
*
|
|
281
|
+
* @param {String} expected
|
|
282
|
+
*/
|
|
283
|
+
jasmine.Matchers.prototype.toThrow = function(expected) {
|
|
284
|
+
var result = false;
|
|
285
|
+
var exception;
|
|
286
|
+
if (typeof this.actual != 'function') {
|
|
287
|
+
throw new Error('Actual is not a function');
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
this.actual();
|
|
291
|
+
} catch (e) {
|
|
292
|
+
exception = e;
|
|
293
|
+
}
|
|
294
|
+
if (exception) {
|
|
295
|
+
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
this.message = function() {
|
|
299
|
+
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
|
300
|
+
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' ');
|
|
301
|
+
} else {
|
|
302
|
+
return "Expected function to throw an exception.";
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return result;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
jasmine.Matchers.Any = function(expectedClass) {
|
|
310
|
+
this.expectedClass = expectedClass;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
jasmine.Matchers.Any.prototype.matches = function(other) {
|
|
314
|
+
if (this.expectedClass == String) {
|
|
315
|
+
return typeof other == 'string' || other instanceof String;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (this.expectedClass == Number) {
|
|
319
|
+
return typeof other == 'number' || other instanceof Number;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (this.expectedClass == Function) {
|
|
323
|
+
return typeof other == 'function' || other instanceof Function;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (this.expectedClass == Object) {
|
|
327
|
+
return typeof other == 'object';
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return other instanceof this.expectedClass;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
jasmine.Matchers.Any.prototype.toString = function() {
|
|
334
|
+
return '<jasmine.any(' + this.expectedClass + ')>';
|
|
335
|
+
};
|
|
336
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @constructor
|
|
3
|
+
*/
|
|
4
|
+
jasmine.MultiReporter = function() {
|
|
5
|
+
this.subReporters_ = [];
|
|
6
|
+
};
|
|
7
|
+
jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
|
|
8
|
+
|
|
9
|
+
jasmine.MultiReporter.prototype.addReporter = function(reporter) {
|
|
10
|
+
this.subReporters_.push(reporter);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
(function() {
|
|
14
|
+
var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
|
|
15
|
+
for (var i = 0; i < functionNames.length; i++) {
|
|
16
|
+
var functionName = functionNames[i];
|
|
17
|
+
jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
|
|
18
|
+
return function() {
|
|
19
|
+
for (var j = 0; j < this.subReporters_.length; j++) {
|
|
20
|
+
var subReporter = this.subReporters_[j];
|
|
21
|
+
if (subReporter[functionName]) {
|
|
22
|
+
subReporter[functionName].apply(subReporter, arguments);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
})(functionName);
|
|
27
|
+
}
|
|
28
|
+
})();
|