Skip to content

Commit

Permalink
Add a not include assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfedr authored and indexzero committed Jan 18, 2013
1 parent 4a9dc5d commit 154b6cd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/assert/macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ assert.include = function (actual, expected, message) {
};
assert.includes = assert.include;

assert.notInclude = function (actual, expected, message) {
if ((function (obj) {
if (isArray(obj) || isString(obj)) {
return obj.indexOf(expected) !== -1;
} else if (isObject(actual)) {
return obj.hasOwnProperty(expected);
}
return true;
})(actual)) {
assert.fail(actual, expected, message || "expected {actual} not to include {expected}", "include", assert.notInclude);
}
};
assert.notIncludes = assert.notIncludes;

assert.deepInclude = function (actual, expected, message) {
if (!isArray(actual)) {
return assert.include(actual, expected, message);
Expand Down

0 comments on commit 154b6cd

Please sign in to comment.