Skip to content

Commit

Permalink
Adding description back to the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrownus committed Sep 24, 2013
1 parent 3f95571 commit 700e53a
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions lib/should.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ Assertion.prototype = {
eql: function(val, description){
this.assert(
eql(val, this.obj)
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) }
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (description ? " | " + description : "") }
, val
, true
, description);
Expand All @@ -315,8 +315,8 @@ Assertion.prototype = {
equal: function(val, description){
this.assert(
val === this.obj
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) }
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (description ? " | " + description : "") }
, val
, void 0
, description);
Expand All @@ -336,8 +336,8 @@ Assertion.prototype = {
var range = start + '..' + finish;
this.assert(
this.obj >= start && this.obj <= finish
, function(){ return 'expected ' + this.inspect + ' to be within ' + range }
, function(){ return 'expected ' + this.inspect + ' to not be within ' + range }
, function(){ return 'expected ' + this.inspect + ' to be within ' + range + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not be within ' + range + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -356,8 +356,8 @@ Assertion.prototype = {
approximately: function(value, delta, description) {
this.assert(
Math.abs(this.obj - value) <= delta
, function(){ return 'expected ' + this.inspect + ' to be approximately ' + value + " +- " + delta }
, function(){ return 'expected ' + this.inspect + ' to not be approximately ' + value + " +- " + delta }
, function(){ return 'expected ' + this.inspect + ' to be approximately ' + value + " +- " + delta + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not be approximately ' + value + " +- " + delta + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -375,8 +375,8 @@ Assertion.prototype = {
a: function(type, description){
this.assert(
type == typeof this.obj
, function(){ return 'expected ' + this.inspect + ' to be a ' + type }
, function(){ return 'expected ' + this.inspect + ' not to be a ' + type }
, function(){ return 'expected ' + this.inspect + ' to be a ' + type + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' not to be a ' + type + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -395,8 +395,8 @@ Assertion.prototype = {
var name = constructor.name;
this.assert(
this.obj instanceof constructor
, function(){ return 'expected ' + this.inspect + ' to be an instance of ' + name }
, function(){ return 'expected ' + this.inspect + ' not to be an instance of ' + name }
, function(){ return 'expected ' + this.inspect + ' to be an instance of ' + name + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' not to be an instance of ' + name + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -414,8 +414,8 @@ Assertion.prototype = {
above: function(n, description){
this.assert(
this.obj > n
, function(){ return 'expected ' + this.inspect + ' to be above ' + n }
, function(){ return 'expected ' + this.inspect + ' to be below ' + n }
, function(){ return 'expected ' + this.inspect + ' to be above ' + n + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to be below ' + n + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -433,8 +433,8 @@ Assertion.prototype = {
below: function(n, description){
this.assert(
this.obj < n
, function(){ return 'expected ' + this.inspect + ' to be below ' + n }
, function(){ return 'expected ' + this.inspect + ' to be above ' + n }
, function(){ return 'expected ' + this.inspect + ' to be below ' + n + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to be above ' + n + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -452,8 +452,8 @@ Assertion.prototype = {
match: function(regexp, description){
this.assert(
regexp.exec(this.obj)
, function(){ return 'expected ' + this.inspect + ' to match ' + regexp }
, function(){ return 'expected ' + this.inspect + ' not to match ' + regexp }
, function(){ return 'expected ' + this.inspect + ' to match ' + regexp + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' not to match ' + regexp + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -473,8 +473,8 @@ Assertion.prototype = {
var len = this.obj.length;
this.assert(
n == len
, function(){ return 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len }
, function(){ return 'expected ' + this.inspect + ' to not have a length of ' + len }
, function(){ return 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not have a length of ' + len + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -498,8 +498,8 @@ Assertion.prototype = {
} else {
this.assert(
undefined !== this.obj[name]
, function(){ return 'expected ' + this.inspect + ' to have a property ' + i(name) }
, function(){ return 'expected ' + this.inspect + ' to not have a property ' + i(name) }
, function(){ return 'expected ' + this.inspect + ' to have a property ' + i(name) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not have a property ' + i(name) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -509,8 +509,8 @@ Assertion.prototype = {
this.assert(
val === this.obj[name]
, function(){ return 'expected ' + this.inspect + ' to have a property ' + i(name)
+ ' of ' + i(val) + ', but got ' + i(this.obj[name]) }
, function(){ return 'expected ' + this.inspect + ' to not have a property ' + i(name) + ' of ' + i(val) }
+ ' of ' + i(val) + ', but got ' + i(this.obj[name]) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not have a property ' + i(name) + ' of ' + i(val) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -531,8 +531,8 @@ Assertion.prototype = {
ownProperty: function(name, description){
this.assert(
this.obj.hasOwnProperty(name)
, function(){ return 'expected ' + this.inspect + ' to have own property ' + i(name) }
, function(){ return 'expected ' + this.inspect + ' to not have own property ' + i(name) }
, function(){ return 'expected ' + this.inspect + ' to have own property ' + i(name) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not have own property ' + i(name) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -549,8 +549,8 @@ Assertion.prototype = {

startWith: function(str, description) {
this.assert(0 === this.obj.indexOf(str)
, function() { return 'expected ' + this.inspect + ' to start with ' + i(str) }
, function() { return 'expected ' + this.inspect + ' to not start with ' + i(str) }
, function() { return 'expected ' + this.inspect + ' to start with ' + i(str) + (description ? " | " + description : "") }
, function() { return 'expected ' + this.inspect + ' to not start with ' + i(str) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -566,8 +566,8 @@ Assertion.prototype = {

endWith: function(str, description) {
this.assert(-1 !== this.obj.indexOf(str, this.obj.length - str.length)
, function() { return 'expected ' + this.inspect + ' to end with ' + i(str) }
, function() { return 'expected ' + this.inspect + ' to not end with ' + i(str) }
, function() { return 'expected ' + this.inspect + ' to end with ' + i(str) + (description ? " | " + description : "") }
, function() { return 'expected ' + this.inspect + ' to not end with ' + i(str) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -588,16 +588,16 @@ Assertion.prototype = {
for (var key in obj) cmp[key] = this.obj[key];
this.assert(
eql(cmp, obj)
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) }
, function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) }
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
} else {
this.assert(
~this.obj.indexOf(obj)
, function(){ return 'expected ' + this.inspect + ' to include ' + i(obj) }
, function(){ return 'expected ' + this.inspect + ' to not include ' + i(obj) }
, function(){ return 'expected ' + this.inspect + ' to include ' + i(obj) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not include ' + i(obj) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand All @@ -616,8 +616,8 @@ Assertion.prototype = {
includeEql: function(obj, description){
this.assert(
this.obj.some(function(item) { return eql(obj, item); })
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) }
, function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) }
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (description ? " | " + description : "") }
, function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) + (description ? " | " + description : "") }
, void 0
, void 0
, description);
Expand Down

0 comments on commit 700e53a

Please sign in to comment.