js-test-driver-rails 0.4.1 → 0.4.2
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/js_test_driver/version.rb +1 -1
- data/vendor/jasmine.js +43 -29
- metadata +1 -1
data/vendor/jasmine.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
var isCommonJS = typeof window == "undefined";
|
2
|
+
|
1
3
|
/**
|
2
4
|
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
3
5
|
*
|
4
6
|
* @namespace
|
5
7
|
*/
|
6
8
|
var jasmine = {};
|
7
|
-
|
9
|
+
if (isCommonJS) exports.jasmine = jasmine;
|
8
10
|
/**
|
9
11
|
* @private
|
10
12
|
*/
|
@@ -106,7 +108,8 @@ jasmine.ExpectationResult.prototype.passed = function () {
|
|
106
108
|
* Getter for the Jasmine environment. Ensures one gets created
|
107
109
|
*/
|
108
110
|
jasmine.getEnv = function() {
|
109
|
-
|
111
|
+
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
112
|
+
return env;
|
110
113
|
};
|
111
114
|
|
112
115
|
/**
|
@@ -169,7 +172,7 @@ jasmine.pp = function(value) {
|
|
169
172
|
* @returns {Boolean}
|
170
173
|
*/
|
171
174
|
jasmine.isDomNode = function(obj) {
|
172
|
-
return obj
|
175
|
+
return obj.nodeType > 0;
|
173
176
|
};
|
174
177
|
|
175
178
|
/**
|
@@ -405,7 +408,7 @@ jasmine.isSpy = function(putativeSpy) {
|
|
405
408
|
* @param {Array} methodNames array of names of methods to make spies
|
406
409
|
*/
|
407
410
|
jasmine.createSpyObj = function(baseName, methodNames) {
|
408
|
-
if (!jasmine.isArray_(methodNames) || methodNames.length
|
411
|
+
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
|
409
412
|
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
410
413
|
}
|
411
414
|
var obj = {};
|
@@ -443,6 +446,7 @@ jasmine.log = function() {
|
|
443
446
|
var spyOn = function(obj, methodName) {
|
444
447
|
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
445
448
|
};
|
449
|
+
if (isCommonJS) exports.spyOn = spyOn;
|
446
450
|
|
447
451
|
/**
|
448
452
|
* Creates a Jasmine spec that will be added to the current suite.
|
@@ -460,6 +464,7 @@ var spyOn = function(obj, methodName) {
|
|
460
464
|
var it = function(desc, func) {
|
461
465
|
return jasmine.getEnv().it(desc, func);
|
462
466
|
};
|
467
|
+
if (isCommonJS) exports.it = it;
|
463
468
|
|
464
469
|
/**
|
465
470
|
* Creates a <em>disabled</em> Jasmine spec.
|
@@ -472,6 +477,7 @@ var it = function(desc, func) {
|
|
472
477
|
var xit = function(desc, func) {
|
473
478
|
return jasmine.getEnv().xit(desc, func);
|
474
479
|
};
|
480
|
+
if (isCommonJS) exports.xit = xit;
|
475
481
|
|
476
482
|
/**
|
477
483
|
* Starts a chain for a Jasmine expectation.
|
@@ -484,6 +490,7 @@ var xit = function(desc, func) {
|
|
484
490
|
var expect = function(actual) {
|
485
491
|
return jasmine.getEnv().currentSpec.expect(actual);
|
486
492
|
};
|
493
|
+
if (isCommonJS) exports.expect = expect;
|
487
494
|
|
488
495
|
/**
|
489
496
|
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
@@ -493,6 +500,7 @@ var expect = function(actual) {
|
|
493
500
|
var runs = function(func) {
|
494
501
|
jasmine.getEnv().currentSpec.runs(func);
|
495
502
|
};
|
503
|
+
if (isCommonJS) exports.runs = runs;
|
496
504
|
|
497
505
|
/**
|
498
506
|
* Waits a fixed time period before moving to the next block.
|
@@ -503,6 +511,7 @@ var runs = function(func) {
|
|
503
511
|
var waits = function(timeout) {
|
504
512
|
jasmine.getEnv().currentSpec.waits(timeout);
|
505
513
|
};
|
514
|
+
if (isCommonJS) exports.waits = waits;
|
506
515
|
|
507
516
|
/**
|
508
517
|
* Waits for the latchFunction to return true before proceeding to the next block.
|
@@ -514,6 +523,7 @@ var waits = function(timeout) {
|
|
514
523
|
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
515
524
|
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
516
525
|
};
|
526
|
+
if (isCommonJS) exports.waitsFor = waitsFor;
|
517
527
|
|
518
528
|
/**
|
519
529
|
* A function that is called before each spec in a suite.
|
@@ -525,6 +535,7 @@ var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout
|
|
525
535
|
var beforeEach = function(beforeEachFunction) {
|
526
536
|
jasmine.getEnv().beforeEach(beforeEachFunction);
|
527
537
|
};
|
538
|
+
if (isCommonJS) exports.beforeEach = beforeEach;
|
528
539
|
|
529
540
|
/**
|
530
541
|
* A function that is called after each spec in a suite.
|
@@ -536,6 +547,7 @@ var beforeEach = function(beforeEachFunction) {
|
|
536
547
|
var afterEach = function(afterEachFunction) {
|
537
548
|
jasmine.getEnv().afterEach(afterEachFunction);
|
538
549
|
};
|
550
|
+
if (isCommonJS) exports.afterEach = afterEach;
|
539
551
|
|
540
552
|
/**
|
541
553
|
* Defines a suite of specifications.
|
@@ -555,6 +567,7 @@ var afterEach = function(afterEachFunction) {
|
|
555
567
|
var describe = function(description, specDefinitions) {
|
556
568
|
return jasmine.getEnv().describe(description, specDefinitions);
|
557
569
|
};
|
570
|
+
if (isCommonJS) exports.describe = describe;
|
558
571
|
|
559
572
|
/**
|
560
573
|
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
@@ -565,27 +578,27 @@ var describe = function(description, specDefinitions) {
|
|
565
578
|
var xdescribe = function(description, specDefinitions) {
|
566
579
|
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
567
580
|
};
|
581
|
+
if (isCommonJS) exports.xdescribe = xdescribe;
|
568
582
|
|
569
583
|
|
570
584
|
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
571
585
|
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
572
|
-
|
573
|
-
|
574
|
-
|
586
|
+
function tryIt(f) {
|
587
|
+
try {
|
588
|
+
return f();
|
589
|
+
} catch(e) {
|
590
|
+
}
|
591
|
+
return null;
|
575
592
|
}
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
return new ActiveXObject("Microsoft.XMLHTTP");
|
586
|
-
} catch(e) {
|
587
|
-
}
|
588
|
-
throw new Error("This browser does not support XMLHttpRequest.");
|
593
|
+
|
594
|
+
var xhr = tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.6.0");}) ||
|
595
|
+
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}) ||
|
596
|
+
tryIt(function(){return new ActiveXObject("Msxml2.XMLHTTP");}) ||
|
597
|
+
tryIt(function(){return new ActiveXObject("Microsoft.XMLHTTP");});
|
598
|
+
|
599
|
+
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
600
|
+
|
601
|
+
return xhr;
|
589
602
|
} : XMLHttpRequest;
|
590
603
|
/**
|
591
604
|
* @namespace
|
@@ -606,7 +619,7 @@ jasmine.util.inherit = function(childClass, parentClass) {
|
|
606
619
|
var subclass = function() {
|
607
620
|
};
|
608
621
|
subclass.prototype = parentClass.prototype;
|
609
|
-
childClass.prototype = new subclass;
|
622
|
+
childClass.prototype = new subclass();
|
610
623
|
};
|
611
624
|
|
612
625
|
jasmine.util.formatException = function(e) {
|
@@ -828,7 +841,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
|
828
841
|
b.__Jasmine_been_here_before__ = a;
|
829
842
|
|
830
843
|
var hasKey = function(obj, keyName) {
|
831
|
-
return obj
|
844
|
+
return obj !== null && obj[keyName] !== jasmine.undefined;
|
832
845
|
};
|
833
846
|
|
834
847
|
for (var property in b) {
|
@@ -854,7 +867,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
|
854
867
|
|
855
868
|
delete a.__Jasmine_been_here_before__;
|
856
869
|
delete b.__Jasmine_been_here_before__;
|
857
|
-
return (mismatchKeys.length
|
870
|
+
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
858
871
|
};
|
859
872
|
|
860
873
|
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
@@ -1302,7 +1315,7 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|
1302
1315
|
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
1303
1316
|
}
|
1304
1317
|
this.message = function() {
|
1305
|
-
if (this.actual.callCount
|
1318
|
+
if (this.actual.callCount === 0) {
|
1306
1319
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
1307
1320
|
return [
|
1308
1321
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
@@ -1333,7 +1346,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
|
1333
1346
|
return [
|
1334
1347
|
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
1335
1348
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
1336
|
-
]
|
1349
|
+
];
|
1337
1350
|
};
|
1338
1351
|
|
1339
1352
|
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
@@ -1390,7 +1403,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|
1390
1403
|
|
1391
1404
|
this.message = function() {
|
1392
1405
|
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
1393
|
-
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "
|
1406
|
+
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
1394
1407
|
} else {
|
1395
1408
|
return "Expected function to throw an exception.";
|
1396
1409
|
}
|
@@ -1602,7 +1615,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
|
1602
1615
|
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
1603
1616
|
for (var property in obj) {
|
1604
1617
|
if (property == '__Jasmine_been_here_before__') continue;
|
1605
|
-
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property)
|
1618
|
+
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
|
1619
|
+
obj.__lookupGetter__(property) !== null) : false);
|
1606
1620
|
}
|
1607
1621
|
};
|
1608
1622
|
|
@@ -2416,6 +2430,6 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
|
|
2416
2430
|
jasmine.version_= {
|
2417
2431
|
"major": 1,
|
2418
2432
|
"minor": 0,
|
2419
|
-
"build":
|
2420
|
-
"revision":
|
2433
|
+
"build": 2,
|
2434
|
+
"revision": 1299565706
|
2421
2435
|
};
|