Browse files

Update mocha (1.7.3) and chai (1.4.0). Closes #84

  • Loading branch information...
1 parent 1fc9cb8 commit a2166e11a41498e63c7b04190e0303af0f6fc3c9 @joliss joliss committed Dec 1, 2012
Showing with 144 additions and 25 deletions.
  1. +2 −0 History.md
  2. +1 −1 chai
  3. +1 −1 mocha
  4. +129 −11 vendor/assets/javascripts/chai.js
  5. +11 −12 vendor/assets/javascripts/mocha.js
View
2 History.md
@@ -1,5 +1,7 @@
# master
+* Update mocha (1.7.3) and chai (1.4.0)
+
# 2.1.0
* Improve capybara-webkit compatibility (#79)
2 chai
@@ -1 +1 @@
-Subproject commit 87880253629ab76ad9a1912139a54341514828d1
+Subproject commit b2642cfb80692f69281321fb760c84956d8569a0
2 mocha
@@ -1 +1 @@
-Subproject commit a22fc7824378889a40e93db4cf97609a481cf341
+Subproject commit f744098a55be2ed76f01289d48744f7142e16c4d
View
140 vendor/assets/javascripts/chai.js
@@ -74,7 +74,7 @@
* Chai version
*/
- exports.version = '1.3.0';
+ exports.version = '1.4.0';
/*!
* Primary `Assertion` prototype
@@ -325,14 +325,17 @@
* - and
* - have
* - with
+ * - at
+ * - of
*
* @name language chains
* @api public
*/
[ 'to', 'be', 'been'
, 'is', 'and', 'have'
- , 'with', 'that' ].forEach(function (chain) {
+ , 'with', 'that', 'at'
+ , 'of' ].forEach(function (chain) {
Assertion.addProperty(chain, function () {
return this;
});
@@ -743,7 +746,7 @@
this.assert(
obj > n
, 'expected #{this} to be above ' + n
- , 'expected #{this} to be below ' + n
+ , 'expected #{this} to be at most ' + n
);
}
}
@@ -753,6 +756,53 @@
Assertion.addMethod('greaterThan', assertAbove);
/**
+ * ### .least(value)
+ *
+ * Asserts that the target is greater than or equal to `value`.
+ *
+ * expect(10).to.be.at.least(10);
+ *
+ * Can also be used in conjunction with `length` to
+ * assert a minimum length. The benefit being a
+ * more informative error message than if the length
+ * was supplied directly.
+ *
+ * expect('foo').to.have.length.of.at.least(2);
+ * expect([ 1, 2, 3 ]).to.have.length.of.at.least(3);
+ *
+ * @name least
+ * @alias gte
+ * @param {Number} value
+ * @param {String} message _optional_
+ * @api public
+ */
+
+ function assertLeast (n, msg) {
+ if (msg) flag(this, 'message', msg);
+ var obj = flag(this, 'object');
+ if (flag(this, 'doLength')) {
+ new Assertion(obj, msg).to.have.property('length');
+ var len = obj.length;
+ this.assert(
+ len >= n
+ , 'expected #{this} to have a length at least #{exp} but got #{act}'
+ , 'expected #{this} to not have a length below #{exp}'
+ , n
+ , len
+ );
+ } else {
+ this.assert(
+ obj >= n
+ , 'expected #{this} to be at least ' + n
+ , 'expected #{this} to be below ' + n
+ );
+ }
+ }
+
+ Assertion.addMethod('least', assertLeast);
+ Assertion.addMethod('gte', assertLeast);
+
+ /**
* ### .below(value)
*
* Asserts that the target is less than `value`.
@@ -792,7 +842,7 @@
this.assert(
obj < n
, 'expected #{this} to be below ' + n
- , 'expected #{this} to be above ' + n
+ , 'expected #{this} to be at least ' + n
);
}
}
@@ -802,6 +852,53 @@
Assertion.addMethod('lessThan', assertBelow);
/**
+ * ### .most(value)
+ *
+ * Asserts that the target is less than or equal to `value`.
+ *
+ * expect(5).to.be.at.most(5);
+ *
+ * Can also be used in conjunction with `length` to
+ * assert a maximum length. The benefit being a
+ * more informative error message than if the length
+ * was supplied directly.
+ *
+ * expect('foo').to.have.length.of.at.most(4);
+ * expect([ 1, 2, 3 ]).to.have.length.of.at.most(3);
+ *
+ * @name most
+ * @alias lte
+ * @param {Number} value
+ * @param {String} message _optional_
+ * @api public
+ */
+
+ function assertMost (n, msg) {
+ if (msg) flag(this, 'message', msg);
+ var obj = flag(this, 'object');
+ if (flag(this, 'doLength')) {
+ new Assertion(obj, msg).to.have.property('length');
+ var len = obj.length;
+ this.assert(
+ len <= n
+ , 'expected #{this} to have a length at most #{exp} but got #{act}'
+ , 'expected #{this} to not have a length above #{exp}'
+ , n
+ , len
+ );
+ } else {
+ this.assert(
+ obj <= n
+ , 'expected #{this} to be at most ' + n
+ , 'expected #{this} to be above ' + n
+ );
+ }
+ }
+
+ Assertion.addMethod('most', assertMost);
+ Assertion.addMethod('lte', assertMost);
+
+ /**
* ### .within(start, finish)
*
* Asserts that the target is within a range.
@@ -2649,7 +2746,7 @@
};
}
- function _deepEqual(actual, expected) {
+ function _deepEqual(actual, expected, memos) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
@@ -2681,7 +2778,7 @@
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
- return objEquiv(actual, expected);
+ return objEquiv(actual, expected, memos);
}
}
@@ -2693,11 +2790,25 @@
return Object.prototype.toString.call(object) == '[object Arguments]';
}
- function objEquiv(a, b) {
+ function objEquiv(a, b, memos) {
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
return false;
+
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
+
+ // check if we have already compared a and b
+ var i;
+ if (memos) {
+ for(i = 0; i < memos.length; i++) {
+ if ((memos[i][0] === a && memos[i][1] === b) ||
+ (memos[i][0] === b && memos[i][1] === a))
+ return true;
+ }
+ } else {
+ memos = [];
+ }
+
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
@@ -2706,19 +2817,21 @@
}
a = pSlice.call(a);
b = pSlice.call(b);
- return _deepEqual(a, b);
+ return _deepEqual(a, b, memos);
}
try {
var ka = Object.keys(a),
kb = Object.keys(b),
- key, i;
+ key;
} catch (e) {//happens when one is a string literal and the other isn't
return false;
}
+
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
+
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
@@ -2727,12 +2840,17 @@
if (ka[i] != kb[i])
return false;
}
+
+ // remember objects we have compared to guard against circular references
+ memos.push([ a, b ]);
+
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
- if (!_deepEqual(a[key], b[key])) return false;
+ if (!_deepEqual(a[key], b[key], memos)) return false;
}
+
return true;
}
@@ -2792,7 +2910,7 @@
module.exports = function (obj, args) {
var actual = args[4];
- return 'undefined' !== actual ? actual : obj._obj;
+ return 'undefined' !== typeof actual ? actual : obj._obj;
};
}); // module: chai/utils/getActual.js
View
23 vendor/assets/javascripts/mocha.js
@@ -1408,7 +1408,7 @@ exports.colors = {
*/
exports.symbols = {
- ok: '',
+ ok: '',
err: '',
dot: ''
};
@@ -1651,7 +1651,7 @@ Base.prototype.epilogue = function(){
}
// pass
- fmt = color('bright pass', ' ' + exports.symbols.ok)
+ fmt = color('bright pass', ' ')
+ color('green', ' %d %s complete')
+ color('light', ' (%s)');
@@ -1662,7 +1662,7 @@ Base.prototype.epilogue = function(){
// pending
if (stats.pending) {
- fmt = color('pending', ' ')
+ fmt = color('pending', ' ')
+ color('pending', ' %d %s pending');
console.log(fmt, stats.pending, pluralize(stats.pending));
@@ -2024,7 +2024,7 @@ function HTML(runner, root) {
});
runner.on('fail', function(test, err){
- if ('hook' == test.type || err.uncaught) runner.emit('test end', test);
+ if ('hook' == test.type) runner.emit('test end', test);
});
runner.on('test end', function(test){
@@ -3909,9 +3909,11 @@ Runner.prototype.checkGlobals = function(test){
Runner.prototype.fail = function(test, err){
++this.failures;
test.state = 'failed';
+
if ('string' == typeof err) {
err = new Error('the string "' + err + '" was thrown, throw an Error :)');
}
+
this.emit('fail', test, err);
};
@@ -4213,15 +4215,10 @@ Runner.prototype.run = function(fn){
debug('start');
- // uncaught callback
- function uncaught(err) {
- self.uncaught(err);
- }
-
// callback
this.on('end', function(){
debug('end');
- process.removeListener('uncaughtException', uncaught);
+ process.removeListener('uncaughtException', self.uncaught.bind(self));
fn(self.failures);
});
@@ -4233,7 +4230,7 @@ Runner.prototype.run = function(fn){
});
// uncaught exception
- process.on('uncaughtException', uncaught);
+ process.on('uncaughtException', this.uncaught.bind(this));
return this;
};
@@ -4944,7 +4941,9 @@ process.removeListener = function(e){
process.on = function(e, fn){
if ('uncaughtException' == e) {
- window.onerror = fn;
+ window.onerror = function(err, url, line){
+ fn(new Error(err + ' (' + url + ':' + line + ')'));
+ };
}
};

0 comments on commit a2166e1

Please sign in to comment.