Skip to content

Commit

Permalink
add mocha .actual / .expected string support for all assertion values
Browse files Browse the repository at this point in the history
so that diffs work
  • Loading branch information
tj committed Jul 30, 2012
1 parent 9feffef commit 05132d3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/should.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,19 @@ Assertion.prototype = {

assert: function(expr, msg, negatedMsg, expected){
var msg = this.negate ? negatedMsg : msg
, ok = this.negate ? !expr : expr;

if (!ok) {
throw new AssertionError({
message: msg
, actual: this.obj
, expected: expected
, stackStartFunction: this.assert
});
}
, ok = this.negate ? !expr : expr
, obj = this.obj;

if (ok) return;
if ('string' != typeof obj) obj = i(obj);
if ('string' != typeof expected) expected = i(expected);

throw new AssertionError({
message: msg
, actual: obj
, expected: expected
, stackStartFunction: this.assert
});
},

/**
Expand Down

0 comments on commit 05132d3

Please sign in to comment.