jasmine-core 1.2.0 → 1.3.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/lib/jasmine-core/jasmine-html.js +77 -12
- data/lib/jasmine-core/jasmine.css +1 -0
- data/lib/jasmine-core/jasmine.js +106 -35
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +113 -87
- data/lib/jasmine-core/spec/core/MatchersSpec.js +48 -2
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +30 -0
- data/lib/jasmine-core/spec/core/RunnerSpec.js +13 -0
- data/lib/jasmine-core/spec/core/SpecRunningSpec.js +117 -84
- data/lib/jasmine-core/spec/core/SpySpec.js +15 -0
- data/lib/jasmine-core/version.rb +1 -1
- metadata +122 -24
@@ -78,6 +78,7 @@ jasmine.HtmlReporter = function(_doc) {
|
|
78
78
|
|
79
79
|
createReporterDom(runner.env.versionString());
|
80
80
|
doc.body.appendChild(dom.reporter);
|
81
|
+
setExceptionHandling();
|
81
82
|
|
82
83
|
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
83
84
|
reporterView.addSpecs(specs, self.specFilter);
|
@@ -131,7 +132,7 @@ jasmine.HtmlReporter = function(_doc) {
|
|
131
132
|
}
|
132
133
|
|
133
134
|
var paramMap = [];
|
134
|
-
var params =
|
135
|
+
var params = jasmine.HtmlReporter.parameters(doc);
|
135
136
|
|
136
137
|
for (var i = 0; i < params.length; i++) {
|
137
138
|
var p = params[i].split('=');
|
@@ -151,14 +152,78 @@ jasmine.HtmlReporter = function(_doc) {
|
|
151
152
|
self.createDom('span', { className: 'version' }, version)),
|
152
153
|
|
153
154
|
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
154
|
-
dom.alert = self.createDom('div', {className: 'alert'}
|
155
|
+
dom.alert = self.createDom('div', {className: 'alert'},
|
156
|
+
self.createDom('span', { className: 'exceptions' },
|
157
|
+
self.createDom('label', { className: 'label', for: 'no_try_catch' }, 'No try/catch'),
|
158
|
+
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
155
159
|
dom.results = self.createDom('div', {className: 'results'},
|
156
160
|
dom.summary = self.createDom('div', { className: 'summary' }),
|
157
161
|
dom.details = self.createDom('div', { id: 'details' }))
|
158
162
|
);
|
159
163
|
}
|
164
|
+
|
165
|
+
function noTryCatch() {
|
166
|
+
return window.location.search.match(/catch=false/);
|
167
|
+
}
|
168
|
+
|
169
|
+
function searchWithCatch() {
|
170
|
+
var params = jasmine.HtmlReporter.parameters(window.document);
|
171
|
+
var removed = false;
|
172
|
+
var i = 0;
|
173
|
+
|
174
|
+
while (!removed && i < params.length) {
|
175
|
+
if (params[i].match(/catch=/)) {
|
176
|
+
params.splice(i, 1);
|
177
|
+
removed = true;
|
178
|
+
}
|
179
|
+
i++;
|
180
|
+
}
|
181
|
+
if (jasmine.CATCH_EXCEPTIONS) {
|
182
|
+
params.push("catch=false");
|
183
|
+
}
|
184
|
+
|
185
|
+
return params.join("&");
|
186
|
+
}
|
187
|
+
|
188
|
+
function setExceptionHandling() {
|
189
|
+
var chxCatch = document.getElementById('no_try_catch');
|
190
|
+
|
191
|
+
if (noTryCatch()) {
|
192
|
+
chxCatch.setAttribute('checked', true);
|
193
|
+
jasmine.CATCH_EXCEPTIONS = false;
|
194
|
+
}
|
195
|
+
chxCatch.onclick = function() {
|
196
|
+
window.location.search = searchWithCatch();
|
197
|
+
};
|
198
|
+
}
|
199
|
+
};
|
200
|
+
jasmine.HtmlReporter.parameters = function(doc) {
|
201
|
+
var paramStr = doc.location.search.substring(1);
|
202
|
+
var params = [];
|
203
|
+
|
204
|
+
if (paramStr.length > 0) {
|
205
|
+
params = paramStr.split('&');
|
206
|
+
}
|
207
|
+
return params;
|
208
|
+
}
|
209
|
+
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
210
|
+
var link = '?';
|
211
|
+
var params = [];
|
212
|
+
|
213
|
+
if (sectionName) {
|
214
|
+
params.push('spec=' + encodeURIComponent(sectionName));
|
215
|
+
}
|
216
|
+
if (!jasmine.CATCH_EXCEPTIONS) {
|
217
|
+
params.push("catch=false");
|
218
|
+
}
|
219
|
+
if (params.length > 0) {
|
220
|
+
link += params.join("&");
|
221
|
+
}
|
222
|
+
|
223
|
+
return link;
|
160
224
|
};
|
161
|
-
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
225
|
+
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
226
|
+
jasmine.HtmlReporter.ReporterView = function(dom) {
|
162
227
|
this.startedAt = new Date();
|
163
228
|
this.runningSpecCount = 0;
|
164
229
|
this.completeSpecCount = 0;
|
@@ -241,14 +306,14 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporte
|
|
241
306
|
|
242
307
|
// currently running UI
|
243
308
|
if (isUndefined(this.runningAlert)) {
|
244
|
-
this.runningAlert = this.createDom('a', {href:
|
309
|
+
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
245
310
|
dom.alert.appendChild(this.runningAlert);
|
246
311
|
}
|
247
312
|
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
248
313
|
|
249
314
|
// skipped specs UI
|
250
315
|
if (isUndefined(this.skippedAlert)) {
|
251
|
-
this.skippedAlert = this.createDom('a', {href:
|
316
|
+
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
252
317
|
}
|
253
318
|
|
254
319
|
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
@@ -259,7 +324,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporte
|
|
259
324
|
|
260
325
|
// passing specs UI
|
261
326
|
if (isUndefined(this.passedAlert)) {
|
262
|
-
this.passedAlert = this.createDom('span', {href:
|
327
|
+
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
|
263
328
|
}
|
264
329
|
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
265
330
|
|
@@ -331,11 +396,11 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
|
331
396
|
this.dom.symbolSummary.appendChild(this.symbol);
|
332
397
|
|
333
398
|
this.summary = this.createDom('div', { className: 'specSummary' },
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
399
|
+
this.createDom('a', {
|
400
|
+
className: 'description',
|
401
|
+
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
402
|
+
title: this.spec.getFullName()
|
403
|
+
}, this.spec.description)
|
339
404
|
);
|
340
405
|
|
341
406
|
this.detail = this.createDom('div', { className: 'specDetail' },
|
@@ -406,7 +471,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.Ht
|
|
406
471
|
this.views = views;
|
407
472
|
|
408
473
|
this.element = this.createDom('div', { className: 'suite' },
|
409
|
-
|
474
|
+
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
410
475
|
);
|
411
476
|
|
412
477
|
this.appendToSummary(this.suite, this.element);
|
@@ -19,6 +19,7 @@ body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
|
19
19
|
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
20
20
|
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
21
21
|
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
22
|
+
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
22
23
|
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
23
24
|
#HTMLReporter .runningAlert { background-color: #666666; }
|
24
25
|
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
data/lib/jasmine-core/jasmine.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var isCommonJS = typeof window == "undefined";
|
1
|
+
var isCommonJS = typeof window == "undefined" && typeof exports == "object";
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
@@ -34,11 +34,23 @@ jasmine.VERBOSE = false;
|
|
34
34
|
*/
|
35
35
|
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
|
36
36
|
|
37
|
+
/**
|
38
|
+
* Maximum levels of nesting that will be included when an object is pretty-printed
|
39
|
+
*/
|
40
|
+
jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
|
41
|
+
|
37
42
|
/**
|
38
43
|
* Default timeout interval in milliseconds for waitsFor() blocks.
|
39
44
|
*/
|
40
45
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
41
46
|
|
47
|
+
/**
|
48
|
+
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
|
49
|
+
* Set to false to let the exception bubble up in the browser.
|
50
|
+
*
|
51
|
+
*/
|
52
|
+
jasmine.CATCH_EXCEPTIONS = true;
|
53
|
+
|
42
54
|
jasmine.getGlobal = function() {
|
43
55
|
function getGlobal() {
|
44
56
|
return this;
|
@@ -463,7 +475,7 @@ jasmine.log = function() {
|
|
463
475
|
* @see jasmine.createSpy
|
464
476
|
* @param obj
|
465
477
|
* @param methodName
|
466
|
-
* @
|
478
|
+
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
|
467
479
|
*/
|
468
480
|
var spyOn = function(obj, methodName) {
|
469
481
|
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
@@ -508,6 +520,7 @@ if (isCommonJS) exports.xit = xit;
|
|
508
520
|
* jasmine.Matchers functions.
|
509
521
|
*
|
510
522
|
* @param {Object} actual Actual value to test against and expected value
|
523
|
+
* @return {jasmine.Matchers}
|
511
524
|
*/
|
512
525
|
var expect = function(actual) {
|
513
526
|
return jasmine.getEnv().currentSpec.expect(actual);
|
@@ -867,6 +880,25 @@ jasmine.Env.prototype.xit = function(desc, func) {
|
|
867
880
|
};
|
868
881
|
};
|
869
882
|
|
883
|
+
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
|
884
|
+
if (a.source != b.source)
|
885
|
+
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
|
886
|
+
|
887
|
+
if (a.ignoreCase != b.ignoreCase)
|
888
|
+
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
|
889
|
+
|
890
|
+
if (a.global != b.global)
|
891
|
+
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
|
892
|
+
|
893
|
+
if (a.multiline != b.multiline)
|
894
|
+
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
|
895
|
+
|
896
|
+
if (a.sticky != b.sticky)
|
897
|
+
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
|
898
|
+
|
899
|
+
return (mismatchValues.length === 0);
|
900
|
+
};
|
901
|
+
|
870
902
|
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
|
871
903
|
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
|
872
904
|
return true;
|
@@ -953,6 +985,10 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
|
953
985
|
return (a == b);
|
954
986
|
}
|
955
987
|
|
988
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
989
|
+
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
|
990
|
+
}
|
991
|
+
|
956
992
|
if (typeof a === "object" && typeof b === "object") {
|
957
993
|
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
958
994
|
}
|
@@ -1019,11 +1055,16 @@ jasmine.Block = function(env, func, spec) {
|
|
1019
1055
|
this.spec = spec;
|
1020
1056
|
};
|
1021
1057
|
|
1022
|
-
jasmine.Block.prototype.execute = function(onComplete) {
|
1023
|
-
|
1058
|
+
jasmine.Block.prototype.execute = function(onComplete) {
|
1059
|
+
if (!jasmine.CATCH_EXCEPTIONS) {
|
1024
1060
|
this.func.apply(this.spec);
|
1025
|
-
}
|
1026
|
-
|
1061
|
+
}
|
1062
|
+
else {
|
1063
|
+
try {
|
1064
|
+
this.func.apply(this.spec);
|
1065
|
+
} catch (e) {
|
1066
|
+
this.spec.fail(e);
|
1067
|
+
}
|
1027
1068
|
}
|
1028
1069
|
onComplete();
|
1029
1070
|
};
|
@@ -1281,6 +1322,17 @@ jasmine.Matchers.prototype.toBeNull = function() {
|
|
1281
1322
|
return (this.actual === null);
|
1282
1323
|
};
|
1283
1324
|
|
1325
|
+
/**
|
1326
|
+
* Matcher that compares the actual to NaN.
|
1327
|
+
*/
|
1328
|
+
jasmine.Matchers.prototype.toBeNaN = function() {
|
1329
|
+
this.message = function() {
|
1330
|
+
return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
|
1331
|
+
};
|
1332
|
+
|
1333
|
+
return (this.actual !== this.actual);
|
1334
|
+
};
|
1335
|
+
|
1284
1336
|
/**
|
1285
1337
|
* Matcher that boolean not-nots the actual.
|
1286
1338
|
*/
|
@@ -1358,18 +1410,14 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|
1358
1410
|
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
1359
1411
|
}
|
1360
1412
|
this.message = function() {
|
1413
|
+
var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
|
1414
|
+
var positiveMessage = "";
|
1361
1415
|
if (this.actual.callCount === 0) {
|
1362
|
-
|
1363
|
-
return [
|
1364
|
-
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
1365
|
-
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
1366
|
-
];
|
1416
|
+
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
|
1367
1417
|
} else {
|
1368
|
-
|
1369
|
-
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
1370
|
-
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
1371
|
-
];
|
1418
|
+
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
|
1372
1419
|
}
|
1420
|
+
return [positiveMessage, invertedMessage];
|
1373
1421
|
};
|
1374
1422
|
|
1375
1423
|
return this.env.contains_(this.actual.argsForCall, expectedArgs);
|
@@ -1427,22 +1475,19 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
|
1427
1475
|
* up to a given level of decimal precision (default 2).
|
1428
1476
|
*
|
1429
1477
|
* @param {Number} expected
|
1430
|
-
* @param {Number} precision
|
1478
|
+
* @param {Number} precision, as number of decimal places
|
1431
1479
|
*/
|
1432
1480
|
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
|
1433
1481
|
if (!(precision === 0)) {
|
1434
1482
|
precision = precision || 2;
|
1435
1483
|
}
|
1436
|
-
|
1437
|
-
var actual = Math.round(this.actual * multiplier);
|
1438
|
-
expected = Math.round(expected * multiplier);
|
1439
|
-
return expected == actual;
|
1484
|
+
return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
|
1440
1485
|
};
|
1441
1486
|
|
1442
1487
|
/**
|
1443
1488
|
* Matcher that checks that the expected exception was thrown by the actual.
|
1444
1489
|
*
|
1445
|
-
* @param {String} expected
|
1490
|
+
* @param {String} [expected]
|
1446
1491
|
*/
|
1447
1492
|
jasmine.Matchers.prototype.toThrow = function(expected) {
|
1448
1493
|
var result = false;
|
@@ -1840,10 +1885,6 @@ jasmine.PrettyPrinter = function() {
|
|
1840
1885
|
* @param value
|
1841
1886
|
*/
|
1842
1887
|
jasmine.PrettyPrinter.prototype.format = function(value) {
|
1843
|
-
if (this.ppNestLevel_ > 40) {
|
1844
|
-
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
1845
|
-
}
|
1846
|
-
|
1847
1888
|
this.ppNestLevel_++;
|
1848
1889
|
try {
|
1849
1890
|
if (value === jasmine.undefined) {
|
@@ -1886,6 +1927,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
|
1886
1927
|
|
1887
1928
|
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
1888
1929
|
for (var property in obj) {
|
1930
|
+
if (!obj.hasOwnProperty(property)) continue;
|
1889
1931
|
if (property == '__Jasmine_been_here_before__') continue;
|
1890
1932
|
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
|
1891
1933
|
obj.__lookupGetter__(property) !== null) : false);
|
@@ -1913,6 +1955,11 @@ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
|
|
1913
1955
|
};
|
1914
1956
|
|
1915
1957
|
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
|
1958
|
+
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
|
1959
|
+
this.append("Array");
|
1960
|
+
return;
|
1961
|
+
}
|
1962
|
+
|
1916
1963
|
this.append('[ ');
|
1917
1964
|
for (var i = 0; i < array.length; i++) {
|
1918
1965
|
if (i > 0) {
|
@@ -1924,6 +1971,11 @@ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
|
|
1924
1971
|
};
|
1925
1972
|
|
1926
1973
|
jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
|
1974
|
+
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
|
1975
|
+
this.append("Object");
|
1976
|
+
return;
|
1977
|
+
}
|
1978
|
+
|
1927
1979
|
var self = this;
|
1928
1980
|
this.append('{ ');
|
1929
1981
|
var first = true;
|
@@ -1952,6 +2004,10 @@ jasmine.StringPrettyPrinter.prototype.append = function(value) {
|
|
1952
2004
|
};
|
1953
2005
|
jasmine.Queue = function(env) {
|
1954
2006
|
this.env = env;
|
2007
|
+
|
2008
|
+
// parallel to blocks. each true value in this array means the block will
|
2009
|
+
// get executed even if we abort
|
2010
|
+
this.ensured = [];
|
1955
2011
|
this.blocks = [];
|
1956
2012
|
this.running = false;
|
1957
2013
|
this.index = 0;
|
@@ -1959,15 +2015,30 @@ jasmine.Queue = function(env) {
|
|
1959
2015
|
this.abort = false;
|
1960
2016
|
};
|
1961
2017
|
|
1962
|
-
jasmine.Queue.prototype.addBefore = function(block) {
|
2018
|
+
jasmine.Queue.prototype.addBefore = function(block, ensure) {
|
2019
|
+
if (ensure === jasmine.undefined) {
|
2020
|
+
ensure = false;
|
2021
|
+
}
|
2022
|
+
|
1963
2023
|
this.blocks.unshift(block);
|
2024
|
+
this.ensured.unshift(ensure);
|
1964
2025
|
};
|
1965
2026
|
|
1966
|
-
jasmine.Queue.prototype.add = function(block) {
|
2027
|
+
jasmine.Queue.prototype.add = function(block, ensure) {
|
2028
|
+
if (ensure === jasmine.undefined) {
|
2029
|
+
ensure = false;
|
2030
|
+
}
|
2031
|
+
|
1967
2032
|
this.blocks.push(block);
|
2033
|
+
this.ensured.push(ensure);
|
1968
2034
|
};
|
1969
2035
|
|
1970
|
-
jasmine.Queue.prototype.insertNext = function(block) {
|
2036
|
+
jasmine.Queue.prototype.insertNext = function(block, ensure) {
|
2037
|
+
if (ensure === jasmine.undefined) {
|
2038
|
+
ensure = false;
|
2039
|
+
}
|
2040
|
+
|
2041
|
+
this.ensured.splice((this.index + this.offset + 1), 0, ensure);
|
1971
2042
|
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
1972
2043
|
this.offset++;
|
1973
2044
|
};
|
@@ -1991,7 +2062,7 @@ jasmine.Queue.prototype.next_ = function() {
|
|
1991
2062
|
while (goAgain) {
|
1992
2063
|
goAgain = false;
|
1993
2064
|
|
1994
|
-
if (self.index < self.blocks.length && !this.abort) {
|
2065
|
+
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
|
1995
2066
|
var calledSynchronously = true;
|
1996
2067
|
var completedSynchronously = false;
|
1997
2068
|
|
@@ -2282,7 +2353,7 @@ jasmine.Spec.prototype.finish = function(onComplete) {
|
|
2282
2353
|
|
2283
2354
|
jasmine.Spec.prototype.after = function(doAfter) {
|
2284
2355
|
if (this.queue.isRunning()) {
|
2285
|
-
this.queue.add(new jasmine.Block(this.env, doAfter, this));
|
2356
|
+
this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
|
2286
2357
|
} else {
|
2287
2358
|
this.afterCallbacks.unshift(doAfter);
|
2288
2359
|
}
|
@@ -2320,15 +2391,15 @@ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
|
|
2320
2391
|
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
|
2321
2392
|
}
|
2322
2393
|
for (i = 0; i < this.afterCallbacks.length; i++) {
|
2323
|
-
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
|
2394
|
+
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
|
2324
2395
|
}
|
2325
2396
|
for (suite = this.suite; suite; suite = suite.parentSuite) {
|
2326
2397
|
for (i = 0; i < suite.after_.length; i++) {
|
2327
|
-
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
|
2398
|
+
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
|
2328
2399
|
}
|
2329
2400
|
}
|
2330
2401
|
for (i = 0; i < runner.after_.length; i++) {
|
2331
|
-
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
|
2402
|
+
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
|
2332
2403
|
}
|
2333
2404
|
};
|
2334
2405
|
|
@@ -2523,7 +2594,7 @@ jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
|
2523
2594
|
|
2524
2595
|
jasmine.version_= {
|
2525
2596
|
"major": 1,
|
2526
|
-
"minor":
|
2597
|
+
"minor": 3,
|
2527
2598
|
"build": 0,
|
2528
|
-
"revision":
|
2599
|
+
"revision": 1354052693
|
2529
2600
|
};
|
@@ -32,118 +32,144 @@ describe('Exceptions:', function() {
|
|
32
32
|
expect(jasmine.util.formatException(sampleWebkitException)).toEqual(expected);
|
33
33
|
});
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
//we run two exception tests to make sure we continue after throwing an exception
|
43
|
-
var suite = env.describe('Suite for handles exceptions', function () {
|
44
|
-
env.it('should be a test that fails because it throws an exception', function() {
|
45
|
-
throw new Error('fake error 1');
|
35
|
+
describe('with break on exception', function() {
|
36
|
+
it('should not catch the exception', function() {
|
37
|
+
var suite = env.describe('suite for break on exceptions', function() {
|
38
|
+
env.it('should break when an exception is thrown', function() {
|
39
|
+
throw new Error('I should hit a breakpoint!');
|
40
|
+
});
|
46
41
|
});
|
42
|
+
var runner = env.currentRunner();
|
43
|
+
var dont_change = 'I will never change!';
|
44
|
+
|
45
|
+
var oldCatch = jasmine.CATCH_EXCEPTIONS;
|
46
|
+
jasmine.CATCH_EXCEPTIONS = false;
|
47
|
+
try {
|
48
|
+
suite.execute();
|
49
|
+
dont_change = 'oops I changed';
|
50
|
+
}
|
51
|
+
catch (e) {}
|
52
|
+
finally {
|
53
|
+
jasmine.CATCH_EXCEPTIONS = oldCatch;
|
54
|
+
}
|
55
|
+
|
56
|
+
expect(dont_change).toEqual('I will never change!');
|
57
|
+
});
|
58
|
+
});
|
47
59
|
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
describe("with catch on exception", function() {
|
61
|
+
it('should handle exceptions thrown, but continue', function() {
|
62
|
+
var fakeTimer = new jasmine.FakeTimer();
|
63
|
+
env.setTimeout = fakeTimer.setTimeout;
|
64
|
+
env.clearTimeout = fakeTimer.clearTimeout;
|
65
|
+
env.setInterval = fakeTimer.setInterval;
|
66
|
+
env.clearInterval = fakeTimer.clearInterval;
|
67
|
+
|
68
|
+
//we run two exception tests to make sure we continue after throwing an exception
|
69
|
+
var suite = env.describe('Suite for handles exceptions', function () {
|
70
|
+
env.it('should be a test that fails because it throws an exception', function() {
|
71
|
+
throw new Error('fake error 1');
|
51
72
|
});
|
52
|
-
this.runs(function () {
|
53
|
-
this.expect(true).toEqual(true);
|
54
|
-
});
|
55
|
-
});
|
56
73
|
|
57
|
-
|
58
|
-
|
59
|
-
|
74
|
+
env.it('should be another test that fails because it throws an exception', function() {
|
75
|
+
this.runs(function () {
|
76
|
+
throw new Error('fake error 2');
|
77
|
+
});
|
78
|
+
this.runs(function () {
|
79
|
+
this.expect(true).toEqual(true);
|
80
|
+
});
|
81
|
+
});
|
60
82
|
|
61
|
-
|
62
|
-
|
63
|
-
var foo = 'foo';
|
83
|
+
env.it('should be a passing test that runs after exceptions are thrown', function() {
|
84
|
+
this.expect(true).toEqual(true);
|
64
85
|
});
|
65
|
-
|
66
|
-
|
67
|
-
|
86
|
+
|
87
|
+
env.it('should be another test that fails because it throws an exception after a wait', function() {
|
88
|
+
this.runs(function () {
|
89
|
+
var foo = 'foo';
|
90
|
+
});
|
91
|
+
this.waits(250);
|
92
|
+
this.runs(function () {
|
93
|
+
throw new Error('fake error 3');
|
94
|
+
});
|
68
95
|
});
|
69
|
-
});
|
70
96
|
|
71
|
-
|
72
|
-
|
97
|
+
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
98
|
+
this.expect(true).toEqual(true);
|
99
|
+
});
|
73
100
|
});
|
74
|
-
});
|
75
|
-
|
76
|
-
var runner = env.currentRunner();
|
77
|
-
suite.execute();
|
78
|
-
fakeTimer.tick(2500);
|
79
101
|
|
80
|
-
|
81
|
-
|
102
|
+
var runner = env.currentRunner();
|
103
|
+
suite.execute();
|
104
|
+
fakeTimer.tick(2500);
|
82
105
|
|
83
|
-
|
84
|
-
|
85
|
-
expect(specResults.length).toEqual(5);
|
86
|
-
expect(specResults[0].passed()).toMatch(false);
|
87
|
-
var blockResults = specResults[0].getItems();
|
88
|
-
expect(blockResults[0].passed()).toEqual(false);
|
89
|
-
expect(blockResults[0].message).toMatch(/fake error 1/);
|
106
|
+
var suiteResults = suite.results();
|
107
|
+
var specResults = suiteResults.getItems();
|
90
108
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
109
|
+
expect(suiteResults.passed()).toEqual(false);
|
110
|
+
//
|
111
|
+
expect(specResults.length).toEqual(5);
|
112
|
+
expect(specResults[0].passed()).toMatch(false);
|
113
|
+
var blockResults = specResults[0].getItems();
|
114
|
+
expect(blockResults[0].passed()).toEqual(false);
|
115
|
+
expect(blockResults[0].message).toMatch(/fake error 1/);
|
96
116
|
|
97
|
-
|
117
|
+
expect(specResults[1].passed()).toEqual(false);
|
118
|
+
blockResults = specResults[1].getItems();
|
119
|
+
expect(blockResults[0].passed()).toEqual(false);
|
120
|
+
expect(blockResults[0].message).toMatch(/fake error 2/);
|
121
|
+
expect(blockResults[1].passed()).toEqual(true);
|
98
122
|
|
99
|
-
|
100
|
-
blockResults = specResults[3].getItems();
|
101
|
-
expect(blockResults[0].message).toMatch(/fake error 3/);
|
123
|
+
expect(specResults[2].passed()).toEqual(true);
|
102
124
|
|
103
|
-
|
104
|
-
|
125
|
+
expect(specResults[3].passed()).toEqual(false);
|
126
|
+
blockResults = specResults[3].getItems();
|
127
|
+
expect(blockResults[0].message).toMatch(/fake error 3/);
|
105
128
|
|
129
|
+
expect(specResults[4].passed()).toEqual(true);
|
130
|
+
});
|
106
131
|
|
107
|
-
|
108
|
-
|
109
|
-
|
132
|
+
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
133
|
+
var suite = env.describe("a top level describe block that throws an exception", function () {
|
134
|
+
env.it("is a test that should pass", function () {
|
110
135
|
this.expect(true).toEqual(true);
|
111
|
-
|
136
|
+
});
|
112
137
|
|
113
|
-
|
114
|
-
|
138
|
+
throw new Error("top level error");
|
139
|
+
});
|
115
140
|
|
116
|
-
|
117
|
-
|
118
|
-
|
141
|
+
suite.execute();
|
142
|
+
var suiteResults = suite.results();
|
143
|
+
var specResults = suiteResults.getItems();
|
119
144
|
|
120
|
-
|
121
|
-
|
145
|
+
expect(suiteResults.passed()).toEqual(false);
|
146
|
+
expect(specResults.length).toEqual(2);
|
122
147
|
|
123
|
-
|
124
|
-
|
148
|
+
expect(specResults[1].description).toMatch(/encountered a declaration exception/);
|
149
|
+
});
|
125
150
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
151
|
+
it("should handle exceptions thrown directly in nested describe blocks and continue", function () {
|
152
|
+
var suite = env.describe("a top level describe", function () {
|
153
|
+
env.describe("a mid-level describe that throws an exception", function () {
|
154
|
+
env.it("is a test that should pass", function () {
|
155
|
+
this.expect(true).toEqual(true);
|
156
|
+
});
|
132
157
|
|
133
|
-
|
134
|
-
|
135
|
-
|
158
|
+
throw new Error("a mid-level error");
|
159
|
+
});
|
160
|
+
});
|
136
161
|
|
137
|
-
|
138
|
-
|
139
|
-
|
162
|
+
suite.execute();
|
163
|
+
var suiteResults = suite.results();
|
164
|
+
var specResults = suiteResults.getItems();
|
140
165
|
|
141
|
-
|
142
|
-
|
166
|
+
expect(suiteResults.passed()).toEqual(false);
|
167
|
+
expect(specResults.length).toEqual(1);
|
143
168
|
|
144
|
-
|
169
|
+
var nestedSpecResults = specResults[0].getItems();
|
145
170
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
});
|
171
|
+
expect(nestedSpecResults.length).toEqual(2);
|
172
|
+
expect(nestedSpecResults[1].description).toMatch(/encountered a declaration exception/);
|
173
|
+
});
|
174
|
+
});
|
175
|
+
});
|
@@ -75,6 +75,18 @@ describe("jasmine.Matchers", function() {
|
|
75
75
|
expect((match(parseInt('5', 10)).toEqual(5))).toPass();
|
76
76
|
expect((match(5).toNotEqual(5))).toFail();
|
77
77
|
expect((match(parseInt('5', 10)).toNotEqual(5))).toFail();
|
78
|
+
|
79
|
+
expect((match(/1/i).toEqual(/1/i))).toPass();
|
80
|
+
expect((match(/1/i).toNotEqual(/1/i))).toFail();
|
81
|
+
expect((match(/[abc]/gm).toEqual(/1/i))).toFail();
|
82
|
+
expect((match(/[abc]/gm).toNotEqual(/1/i))).toPass();
|
83
|
+
|
84
|
+
// only test if the browser supports the sticky option on a regExp see pull #234
|
85
|
+
if (RegExp.prototype.sticky !== undefined) {
|
86
|
+
var sticky_regexp = new RegExp("[abc]", "y");
|
87
|
+
expect((match(sticky_regexp).toEqual(/1/i))).toFail();
|
88
|
+
expect((match(sticky_regexp).toNotEqual(/1/i))).toPass();
|
89
|
+
}
|
78
90
|
});
|
79
91
|
|
80
92
|
it("toEqual to build an Expectation Result", function() {
|
@@ -281,6 +293,29 @@ describe("jasmine.Matchers", function() {
|
|
281
293
|
expect(result.actual).toEqual(actual);
|
282
294
|
});
|
283
295
|
|
296
|
+
it("toBeNaN", function() {
|
297
|
+
expect(match(Number.NaN).toBeNaN()).toPass();
|
298
|
+
expect(match(0).toBeNaN()).toFail();
|
299
|
+
expect(match(1).toBeNaN()).toFail();
|
300
|
+
expect(match(null).toBeNaN()).toFail();
|
301
|
+
expect(match(Number.POSITIVE_INFINITY).toBeNaN()).toFail();
|
302
|
+
expect(match(Number.NEGATIVE_INFINITY).toBeNaN()).toFail();
|
303
|
+
expect(match('NaN').toBeNaN()).toFail();
|
304
|
+
});
|
305
|
+
|
306
|
+
it("toBeNaN to build an ExpectationResult", function() {
|
307
|
+
var actual = 'a';
|
308
|
+
var matcher = match(actual);
|
309
|
+
matcher.toBeNaN();
|
310
|
+
|
311
|
+
var result = lastResult();
|
312
|
+
|
313
|
+
expect(result.matcherName).toEqual("toBeNaN");
|
314
|
+
expect(result.passed()).toFail();
|
315
|
+
expect(result.message).toMatch("Expected 'a' to be NaN.");
|
316
|
+
expect(result.actual).toMatch(actual);
|
317
|
+
});
|
318
|
+
|
284
319
|
it("toBeFalsy", function() {
|
285
320
|
expect(match(false).toBeFalsy()).toPass();
|
286
321
|
expect(match(true).toBeFalsy()).toFail();
|
@@ -510,6 +545,11 @@ describe("jasmine.Matchers", function() {
|
|
510
545
|
expect(-1.23).not.toBeCloseTo(-1.24);
|
511
546
|
});
|
512
547
|
|
548
|
+
it("expects close numbers to 'be close' and further numbers not to", function() {
|
549
|
+
expect(1.225).not.toBeCloseTo(1.234); // difference is 0.009
|
550
|
+
expect(1.225).toBeCloseTo(1.224); // difference is 0.001
|
551
|
+
});
|
552
|
+
|
513
553
|
it("accepts an optional precision argument", function() {
|
514
554
|
expect(1).toBeCloseTo(1.1, 0);
|
515
555
|
expect(1.2).toBeCloseTo(1.23, 1);
|
@@ -771,7 +811,13 @@ describe("jasmine.Matchers", function() {
|
|
771
811
|
TestClass.spyFunction('d', 'e', 'f');
|
772
812
|
var expected = match(TestClass.spyFunction);
|
773
813
|
expect(expected.toHaveBeenCalledWith('a', 'b')).toFail();
|
774
|
-
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but
|
814
|
+
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ]");
|
815
|
+
});
|
816
|
+
|
817
|
+
it("should return a decent message when it hasn't been called", function() {
|
818
|
+
var expected = match(TestClass.spyFunction);
|
819
|
+
expect(expected.toHaveBeenCalledWith('a', 'b')).toFail();
|
820
|
+
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but it was never called.");
|
775
821
|
});
|
776
822
|
|
777
823
|
it("should return a decent message when inverted", function() {
|
@@ -779,7 +825,7 @@ describe("jasmine.Matchers", function() {
|
|
779
825
|
TestClass.spyFunction('d', 'e', 'f');
|
780
826
|
var expected = match(TestClass.spyFunction);
|
781
827
|
expect(expected.not.toHaveBeenCalledWith('a', 'b', 'c')).toFail();
|
782
|
-
expect(lastResult().message).toEqual("Expected spy My spy not to have been called with [ 'a', 'b', 'c' ] but was
|
828
|
+
expect(lastResult().message).toEqual("Expected spy My spy not to have been called with [ 'a', 'b', 'c' ] but it was.");
|
783
829
|
});
|
784
830
|
|
785
831
|
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('toHaveBeenCalledWith'));
|
@@ -32,6 +32,36 @@ describe("jasmine.pp", function () {
|
|
32
32
|
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
33
33
|
});
|
34
34
|
|
35
|
+
it("should not include inherited properties when stringifying an object", function() {
|
36
|
+
var SomeClass = function() {};
|
37
|
+
SomeClass.prototype.foo = "inherited foo";
|
38
|
+
var instance = new SomeClass();
|
39
|
+
instance.bar = "my own bar";
|
40
|
+
expect(jasmine.pp(instance)).toEqual("{ bar : 'my own bar' }");
|
41
|
+
});
|
42
|
+
|
43
|
+
it("should not recurse objects and arrays more deeply than jasmine.MAX_PRETTY_PRINT_DEPTH", function() {
|
44
|
+
var originalMaxDepth = jasmine.MAX_PRETTY_PRINT_DEPTH;
|
45
|
+
var nestedObject = { level1: { level2: { level3: { level4: "leaf" } } } };
|
46
|
+
var nestedArray = [1, [2, [3, [4, "leaf"]]]];
|
47
|
+
|
48
|
+
try {
|
49
|
+
jasmine.MAX_PRETTY_PRINT_DEPTH = 2;
|
50
|
+
expect(jasmine.pp(nestedObject)).toEqual("{ level1 : { level2 : Object } }");
|
51
|
+
expect(jasmine.pp(nestedArray)).toEqual("[ 1, [ 2, Array ] ]");
|
52
|
+
|
53
|
+
jasmine.MAX_PRETTY_PRINT_DEPTH = 3;
|
54
|
+
expect(jasmine.pp(nestedObject)).toEqual("{ level1 : { level2 : { level3 : Object } } }");
|
55
|
+
expect(jasmine.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, Array ] ] ]");
|
56
|
+
|
57
|
+
jasmine.MAX_PRETTY_PRINT_DEPTH = 4;
|
58
|
+
expect(jasmine.pp(nestedObject)).toEqual("{ level1 : { level2 : { level3 : { level4 : 'leaf' } } } }");
|
59
|
+
expect(jasmine.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, [ 4, 'leaf' ] ] ] ]");
|
60
|
+
} finally {
|
61
|
+
jasmine.MAX_PRETTY_PRINT_DEPTH = originalMaxDepth;
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
35
65
|
it("should stringify RegExp objects properly", function() {
|
36
66
|
expect(jasmine.pp(/x|y|z/)).toEqual("/x|y|z/");
|
37
67
|
});
|
@@ -105,6 +105,19 @@ describe('RunnerTest', function() {
|
|
105
105
|
expect(runnerResults.totalCount).toEqual(3);
|
106
106
|
expect(runnerResults.passedCount).toEqual(3);
|
107
107
|
});
|
108
|
+
|
109
|
+
it('should run after a failing spec', function () {
|
110
|
+
var afterEach = jasmine.createSpy();
|
111
|
+
env.afterEach(afterEach);
|
112
|
+
|
113
|
+
env.describe('suite', function () {
|
114
|
+
env.it('fails', function () {
|
115
|
+
this.explodes();
|
116
|
+
});
|
117
|
+
}).execute();
|
118
|
+
|
119
|
+
expect(afterEach).toHaveBeenCalled();
|
120
|
+
});
|
108
121
|
});
|
109
122
|
|
110
123
|
|
@@ -398,6 +398,123 @@ describe("jasmine spec running", function () {
|
|
398
398
|
expect(timeoutSpec.results().getItems()[0].message).toEqual('timeout: timed out after 500 msec waiting for something to happen');
|
399
399
|
expect(subsequentSpecRan).toEqual(true);
|
400
400
|
});
|
401
|
+
|
402
|
+
it("runs afterEach after timing out", function() {
|
403
|
+
var afterEach = jasmine.createSpy('afterEach');
|
404
|
+
|
405
|
+
env.describe('foo', function () {
|
406
|
+
env.afterEach(afterEach);
|
407
|
+
|
408
|
+
env.it('waitsFor', function () {
|
409
|
+
this.waitsFor(100, function() {
|
410
|
+
return false;
|
411
|
+
});
|
412
|
+
});
|
413
|
+
}).execute();
|
414
|
+
|
415
|
+
fakeTimer.tick(500);
|
416
|
+
expect(afterEach).toHaveBeenCalled();
|
417
|
+
});
|
418
|
+
|
419
|
+
it("runs single-spec after functions after timing out", function() {
|
420
|
+
var after = jasmine.createSpy('after');
|
421
|
+
|
422
|
+
env.describe('foo', function () {
|
423
|
+
env.it('waitsFor', function () {
|
424
|
+
this.after(after);
|
425
|
+
this.waitsFor(100, function() {
|
426
|
+
return false;
|
427
|
+
});
|
428
|
+
});
|
429
|
+
}).execute();
|
430
|
+
|
431
|
+
fakeTimer.tick(500);
|
432
|
+
expect(after).toHaveBeenCalled();
|
433
|
+
});
|
434
|
+
|
435
|
+
describe('with consecutive calls', function () {
|
436
|
+
var foo;
|
437
|
+
beforeEach(function () {
|
438
|
+
foo = 0;
|
439
|
+
});
|
440
|
+
|
441
|
+
it('exits immediately (does not stack) if the latchFunction times out', function () {
|
442
|
+
var reachedFirstWaitsFor = false;
|
443
|
+
var reachedSecondWaitsFor = false;
|
444
|
+
env.describe('suite that waits', function () {
|
445
|
+
env.it('should stack timeouts', function() {
|
446
|
+
this.waitsFor(500, function () {
|
447
|
+
reachedFirstWaitsFor = true;
|
448
|
+
return false;
|
449
|
+
});
|
450
|
+
this.waitsFor(500, function () {
|
451
|
+
reachedSecondWaitsFor = true;
|
452
|
+
});
|
453
|
+
this.runs(function () {
|
454
|
+
foo++;
|
455
|
+
});
|
456
|
+
});
|
457
|
+
});
|
458
|
+
|
459
|
+
expect(reachedFirstWaitsFor).toEqual(false);
|
460
|
+
env.execute();
|
461
|
+
|
462
|
+
expect(reachedFirstWaitsFor).toEqual(true);
|
463
|
+
expect(foo).toEqual(0);
|
464
|
+
expect(reachedSecondWaitsFor).toEqual(false);
|
465
|
+
fakeTimer.tick(500);
|
466
|
+
expect(reachedSecondWaitsFor).toEqual(false);
|
467
|
+
expect(foo).toEqual(0);
|
468
|
+
fakeTimer.tick(500);
|
469
|
+
expect(reachedSecondWaitsFor).toEqual(false);
|
470
|
+
expect(foo).toEqual(0);
|
471
|
+
});
|
472
|
+
|
473
|
+
it('stacks latchFunctions', function () {
|
474
|
+
var firstWaitsResult = false;
|
475
|
+
var secondWaitsResult = false;
|
476
|
+
var waitsSuite = env.describe('suite that waits', function () {
|
477
|
+
env.it('spec with waitsFors', function() {
|
478
|
+
this.waitsFor(600, function () {
|
479
|
+
fakeTimer.setTimeout(function () {
|
480
|
+
firstWaitsResult = true;
|
481
|
+
}, 300);
|
482
|
+
return firstWaitsResult;
|
483
|
+
});
|
484
|
+
this.waitsFor(600, function () {
|
485
|
+
fakeTimer.setTimeout(function () {
|
486
|
+
secondWaitsResult = true;
|
487
|
+
}, 300);
|
488
|
+
return secondWaitsResult;
|
489
|
+
});
|
490
|
+
this.runs(function () {
|
491
|
+
foo++;
|
492
|
+
});
|
493
|
+
});
|
494
|
+
});
|
495
|
+
|
496
|
+
expect(firstWaitsResult).toEqual(false);
|
497
|
+
expect(secondWaitsResult).toEqual(false);
|
498
|
+
waitsSuite.execute();
|
499
|
+
|
500
|
+
expect(firstWaitsResult).toEqual(false);
|
501
|
+
expect(secondWaitsResult).toEqual(false);
|
502
|
+
expect(foo).toEqual(0);
|
503
|
+
|
504
|
+
fakeTimer.tick(300);
|
505
|
+
|
506
|
+
expect(firstWaitsResult).toEqual(true);
|
507
|
+
expect(secondWaitsResult).toEqual(false);
|
508
|
+
expect(foo).toEqual(0);
|
509
|
+
|
510
|
+
fakeTimer.tick(300);
|
511
|
+
|
512
|
+
expect(firstWaitsResult).toEqual(true);
|
513
|
+
expect(secondWaitsResult).toEqual(true);
|
514
|
+
expect(foo).toEqual(1);
|
515
|
+
|
516
|
+
});
|
517
|
+
});
|
401
518
|
});
|
402
519
|
|
403
520
|
it("testSpecAfter", function() {
|
@@ -579,90 +696,6 @@ describe("jasmine spec running", function () {
|
|
579
696
|
expect(quux).toEqual(1);
|
580
697
|
});
|
581
698
|
|
582
|
-
describe('#waitsFor should allow consecutive calls', function () {
|
583
|
-
var foo;
|
584
|
-
beforeEach(function () {
|
585
|
-
foo = 0;
|
586
|
-
});
|
587
|
-
|
588
|
-
it('exits immediately (does not stack) if the latchFunction times out', function () {
|
589
|
-
var reachedFirstWaitsFor = false;
|
590
|
-
var reachedSecondWaitsFor = false;
|
591
|
-
env.describe('suite that waits', function () {
|
592
|
-
env.it('should stack timeouts', function() {
|
593
|
-
this.waitsFor(500, function () {
|
594
|
-
reachedFirstWaitsFor = true;
|
595
|
-
return false;
|
596
|
-
});
|
597
|
-
this.waitsFor(500, function () {
|
598
|
-
reachedSecondWaitsFor = true;
|
599
|
-
});
|
600
|
-
this.runs(function () {
|
601
|
-
foo++;
|
602
|
-
});
|
603
|
-
});
|
604
|
-
});
|
605
|
-
|
606
|
-
expect(reachedFirstWaitsFor).toEqual(false);
|
607
|
-
env.execute();
|
608
|
-
|
609
|
-
expect(reachedFirstWaitsFor).toEqual(true);
|
610
|
-
expect(foo).toEqual(0);
|
611
|
-
expect(reachedSecondWaitsFor).toEqual(false);
|
612
|
-
fakeTimer.tick(500);
|
613
|
-
expect(reachedSecondWaitsFor).toEqual(false);
|
614
|
-
expect(foo).toEqual(0);
|
615
|
-
fakeTimer.tick(500);
|
616
|
-
expect(reachedSecondWaitsFor).toEqual(false);
|
617
|
-
expect(foo).toEqual(0);
|
618
|
-
});
|
619
|
-
|
620
|
-
it('stacks latchFunctions', function () {
|
621
|
-
var firstWaitsResult = false;
|
622
|
-
var secondWaitsResult = false;
|
623
|
-
var waitsSuite = env.describe('suite that waits', function () {
|
624
|
-
env.it('spec with waitsFors', function() {
|
625
|
-
this.waitsFor(600, function () {
|
626
|
-
fakeTimer.setTimeout(function () {
|
627
|
-
firstWaitsResult = true;
|
628
|
-
}, 300);
|
629
|
-
return firstWaitsResult;
|
630
|
-
});
|
631
|
-
this.waitsFor(600, function () {
|
632
|
-
fakeTimer.setTimeout(function () {
|
633
|
-
secondWaitsResult = true;
|
634
|
-
}, 300);
|
635
|
-
return secondWaitsResult;
|
636
|
-
});
|
637
|
-
this.runs(function () {
|
638
|
-
foo++;
|
639
|
-
});
|
640
|
-
});
|
641
|
-
});
|
642
|
-
|
643
|
-
expect(firstWaitsResult).toEqual(false);
|
644
|
-
expect(secondWaitsResult).toEqual(false);
|
645
|
-
waitsSuite.execute();
|
646
|
-
|
647
|
-
expect(firstWaitsResult).toEqual(false);
|
648
|
-
expect(secondWaitsResult).toEqual(false);
|
649
|
-
expect(foo).toEqual(0);
|
650
|
-
|
651
|
-
fakeTimer.tick(300);
|
652
|
-
|
653
|
-
expect(firstWaitsResult).toEqual(true);
|
654
|
-
expect(secondWaitsResult).toEqual(false);
|
655
|
-
expect(foo).toEqual(0);
|
656
|
-
|
657
|
-
fakeTimer.tick(300);
|
658
|
-
|
659
|
-
expect(firstWaitsResult).toEqual(true);
|
660
|
-
expect(secondWaitsResult).toEqual(true);
|
661
|
-
expect(foo).toEqual(1);
|
662
|
-
|
663
|
-
});
|
664
|
-
});
|
665
|
-
|
666
699
|
it("#beforeEach should be able to eval runs and waits blocks", function () {
|
667
700
|
var foo = 0;
|
668
701
|
var bar = 0;
|
@@ -165,6 +165,21 @@ describe('Spies', function () {
|
|
165
165
|
expect(exception).toBeDefined();
|
166
166
|
});
|
167
167
|
|
168
|
+
|
169
|
+
it('to spy on an undefined method throws exception', function() {
|
170
|
+
var TestClass = {
|
171
|
+
someFunction : function() {
|
172
|
+
}
|
173
|
+
};
|
174
|
+
function efunc() {
|
175
|
+
this.spyOn(TestClass, 'someOtherFunction');
|
176
|
+
};
|
177
|
+
expect(function() {
|
178
|
+
efunc();
|
179
|
+
}).toThrow('someOtherFunction() method does not exist');
|
180
|
+
|
181
|
+
});
|
182
|
+
|
168
183
|
it('should be able to reset a spy', function() {
|
169
184
|
var TestClass = { someFunction: function() {} };
|
170
185
|
this.spyOn(TestClass, 'someFunction');
|
data/lib/jasmine-core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json_pure
|
18
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,15 @@ dependencies:
|
|
23
23
|
version: 1.4.3
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.4.3
|
27
32
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement:
|
33
|
+
name: tilt
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
30
35
|
none: false
|
31
36
|
requirements:
|
32
37
|
- - ! '>='
|
@@ -34,10 +39,15 @@ dependencies:
|
|
34
39
|
version: '0'
|
35
40
|
type: :development
|
36
41
|
prerelease: false
|
37
|
-
version_requirements:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
38
48
|
- !ruby/object:Gem::Dependency
|
39
49
|
name: sass
|
40
|
-
requirement:
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
41
51
|
none: false
|
42
52
|
requirements:
|
43
53
|
- - ! '>='
|
@@ -45,10 +55,15 @@ dependencies:
|
|
45
55
|
version: '0'
|
46
56
|
type: :development
|
47
57
|
prerelease: false
|
48
|
-
version_requirements:
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
49
64
|
- !ruby/object:Gem::Dependency
|
50
65
|
name: compass
|
51
|
-
requirement:
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
52
67
|
none: false
|
53
68
|
requirements:
|
54
69
|
- - ! '>='
|
@@ -56,10 +71,15 @@ dependencies:
|
|
56
71
|
version: '0'
|
57
72
|
type: :development
|
58
73
|
prerelease: false
|
59
|
-
version_requirements:
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
60
80
|
- !ruby/object:Gem::Dependency
|
61
81
|
name: ragaskar-jsdoc_helper
|
62
|
-
requirement:
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
63
83
|
none: false
|
64
84
|
requirements:
|
65
85
|
- - ! '>='
|
@@ -67,10 +87,15 @@ dependencies:
|
|
67
87
|
version: '0'
|
68
88
|
type: :development
|
69
89
|
prerelease: false
|
70
|
-
version_requirements:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
71
96
|
- !ruby/object:Gem::Dependency
|
72
97
|
name: rspec
|
73
|
-
requirement:
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
74
99
|
none: false
|
75
100
|
requirements:
|
76
101
|
- - ! '>='
|
@@ -78,10 +103,15 @@ dependencies:
|
|
78
103
|
version: '0'
|
79
104
|
type: :development
|
80
105
|
prerelease: false
|
81
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
82
112
|
- !ruby/object:Gem::Dependency
|
83
113
|
name: fuubar
|
84
|
-
requirement:
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
85
115
|
none: false
|
86
116
|
requirements:
|
87
117
|
- - ! '>='
|
@@ -89,10 +119,15 @@ dependencies:
|
|
89
119
|
version: '0'
|
90
120
|
type: :development
|
91
121
|
prerelease: false
|
92
|
-
version_requirements:
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
93
128
|
- !ruby/object:Gem::Dependency
|
94
129
|
name: awesome_print
|
95
|
-
requirement:
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
96
131
|
none: false
|
97
132
|
requirements:
|
98
133
|
- - ! '>='
|
@@ -100,10 +135,15 @@ dependencies:
|
|
100
135
|
version: '0'
|
101
136
|
type: :development
|
102
137
|
prerelease: false
|
103
|
-
version_requirements:
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
104
144
|
- !ruby/object:Gem::Dependency
|
105
145
|
name: thor
|
106
|
-
requirement:
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
107
147
|
none: false
|
108
148
|
requirements:
|
109
149
|
- - ! '>='
|
@@ -111,10 +151,47 @@ dependencies:
|
|
111
151
|
version: '0'
|
112
152
|
type: :development
|
113
153
|
prerelease: false
|
114
|
-
version_requirements:
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
115
160
|
- !ruby/object:Gem::Dependency
|
116
161
|
name: nokogiri
|
117
|
-
requirement:
|
162
|
+
requirement: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ! '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
- !ruby/object:Gem::Dependency
|
177
|
+
name: redcarpet
|
178
|
+
requirement: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
180
|
+
requirements:
|
181
|
+
- - '='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '1.7'
|
184
|
+
type: :development
|
185
|
+
prerelease: false
|
186
|
+
version_requirements: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - '='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '1.7'
|
192
|
+
- !ruby/object:Gem::Dependency
|
193
|
+
name: rocco
|
194
|
+
requirement: !ruby/object:Gem::Requirement
|
118
195
|
none: false
|
119
196
|
requirements:
|
120
197
|
- - ! '>='
|
@@ -122,7 +199,28 @@ dependencies:
|
|
122
199
|
version: '0'
|
123
200
|
type: :development
|
124
201
|
prerelease: false
|
125
|
-
version_requirements:
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
- !ruby/object:Gem::Dependency
|
209
|
+
name: rdiscount
|
210
|
+
requirement: !ruby/object:Gem::Requirement
|
211
|
+
none: false
|
212
|
+
requirements:
|
213
|
+
- - ! '>='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
none: false
|
220
|
+
requirements:
|
221
|
+
- - ! '>='
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
126
224
|
description: Test your JavaScript without any framework dependencies, in any environment,
|
127
225
|
and with a nice descriptive syntax.
|
128
226
|
email: jasmine-js@googlegroups.com
|
@@ -187,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
285
|
version: '0'
|
188
286
|
requirements: []
|
189
287
|
rubyforge_project: jasmine-core
|
190
|
-
rubygems_version: 1.8.
|
288
|
+
rubygems_version: 1.8.24
|
191
289
|
signing_key:
|
192
290
|
specification_version: 3
|
193
291
|
summary: JavaScript BDD framework
|