Skip to content

Commit

Permalink
added assert.length & assert.isFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed May 11, 2010
1 parent 99eb7de commit e43aa0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/vows/macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ assert.isEmpty = function (actual, message) {
}
};

assert.length = function (actual, expected, message) {
if (actual.length !== expected) {
assert.fail(actual, expected, message || "expected {actual} to have {expected} elements", "length", assert.length);
}
};

assert.isArray = function (actual, message) {
assertTypeOf(actual, 'array', message || "expected {actual} to be an Array", assert.isArray);
};
Expand All @@ -62,6 +68,9 @@ assert.isNumber = function (actual, message) {
assert.isString = function (actual, message) {
assertTypeOf(actual, 'string', message || "expected {actual} to be a String", assert.isString);
};
assert.isFunction = function (actual, message) {
assertTypeOf(actual, 'function', message || "expected {actual} to be a Function", assert.isFunction);
};
assert.typeOf = function (actual, expected, message) {
assertTypeOf(actual, expected, message, assert.typeOf);
};
Expand Down
3 changes: 3 additions & 0 deletions test/vows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ vows.describe("Vows").addVows({
"testing match": function (it) {
assert.match(it, /[a-z]+ [a-z]+/);
},
"testing length": function (it) {
assert.length(it, 11);
},
"testing inclusion": function (it) {
assert.include(it, "world");
},
Expand Down

0 comments on commit e43aa0e

Please sign in to comment.