Comparing version
@@ -0,1 +1,6 @@ | ||
2.1.1 / 2013-12-05 | ||
================== | ||
* Move date formatting out of should.inspect | ||
2.1.0 / 2013-11-11 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -27,7 +27,9 @@ /*! | ||
should.inspect = function(obj, opts) { | ||
if(util.isDate(obj) && typeof obj.inspect !== 'function') obj = obj.toISOString(); | ||
return inspect(obj, opts); | ||
}; | ||
should.inspect = inspect; | ||
function i(value) { | ||
if(util.isDate(value) && typeof value.inspect !== 'function') return value.toISOString(); //show millis in dates | ||
return should.inspect(value); | ||
} | ||
/** | ||
@@ -55,3 +57,3 @@ * Expose assert to should | ||
throw new AssertionError({ | ||
message: msg || ('expected ' + should.inspect(obj) + ' to exist') | ||
message: msg || ('expected ' + i(obj) + ' to exist') | ||
, stackStartFunction: should.exist | ||
@@ -74,3 +76,3 @@ }); | ||
throw new AssertionError({ | ||
message: msg || ('expected ' + should.inspect(obj) + ' to not exist') | ||
message: msg || ('expected ' + i(obj) + ' to not exist') | ||
, stackStartFunction: should.not.exist | ||
@@ -243,3 +245,3 @@ }); | ||
get inspect() { | ||
return should.inspect(this.obj); | ||
return i(this.obj); | ||
}, | ||
@@ -374,4 +376,4 @@ | ||
eql(val, this.obj) | ||
, function(){ return 'expected ' + this.inspect + ' to equal ' + should.inspect(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not equal ' + should.inspect(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (description ? " | " + description : "") } | ||
, val | ||
@@ -394,4 +396,4 @@ , true | ||
val === this.obj | ||
, function(){ return 'expected ' + this.inspect + ' to equal ' + should.inspect(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not equal ' + should.inspect(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to equal ' + i(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not equal ' + i(val) + (description ? " | " + description : "") } | ||
, val | ||
@@ -648,3 +650,3 @@ , void 0 | ||
if (undefined === this.obj[name]) { | ||
throw new Error(this.inspect + ' has no property ' + should.inspect(name) + (description ? " | " + description : "")); | ||
throw new Error(this.inspect + ' has no property ' + i(name) + (description ? " | " + description : "")); | ||
} | ||
@@ -654,4 +656,4 @@ } else { | ||
undefined !== this.obj[name] | ||
, function(){ return 'expected ' + this.inspect + ' to have a property ' + should.inspect(name) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not have a property ' + should.inspect(name) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -665,5 +667,5 @@ , void 0 | ||
val === this.obj[name] | ||
, function(){ return 'expected ' + this.inspect + ' to have a property ' + should.inspect(name) | ||
+ ' of ' + should.inspect(val) + ', but got ' + should.inspect(this.obj[name]) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not have a property ' + should.inspect(name) + ' of ' + should.inspect(val) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to have a property ' + i(name) | ||
+ ' 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 | ||
@@ -702,3 +704,3 @@ , void 0 | ||
names = names.map(function(name){ | ||
return should.inspect(name); | ||
return i(name); | ||
}); | ||
@@ -708,3 +710,3 @@ var last = names.pop(); | ||
} else { | ||
str = should.inspect(names[0]); | ||
str = i(names[0]); | ||
} | ||
@@ -734,4 +736,4 @@ | ||
hasOwnProperty.call(this.obj, name) | ||
, function(){ return 'expected ' + this.inspect + ' to have own property ' + should.inspect(name) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not have own property ' + should.inspect(name) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -753,4 +755,4 @@ , void 0 | ||
this.assert(0 === this.obj.indexOf(str) | ||
, function() { return 'expected ' + this.inspect + ' to start with ' + should.inspect(str) + (description ? " | " + description : "") } | ||
, function() { return 'expected ' + this.inspect + ' to not start with ' + should.inspect(str) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -771,4 +773,4 @@ , void 0 | ||
this.assert(-1 !== this.obj.indexOf(str, this.obj.length - str.length) | ||
, function() { return 'expected ' + this.inspect + ' to end with ' + should.inspect(str) + (description ? " | " + description : "") } | ||
, function() { return 'expected ' + this.inspect + ' to not end with ' + should.inspect(str) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -794,4 +796,4 @@ , void 0 | ||
eql(cmp, obj) | ||
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -803,4 +805,4 @@ , void 0 | ||
~this.obj.indexOf(obj) | ||
, function(){ return 'expected ' + this.inspect + ' to include ' + should.inspect(obj) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not include ' + should.inspect(obj) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -824,4 +826,4 @@ , void 0 | ||
this.obj.some(function(item) { return eql(obj, item); }) | ||
, function(){ return 'expected ' + this.inspect + ' to include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") } | ||
, function(){ return 'expected ' + this.inspect + ' to not include an object equal to ' + should.inspect(obj) + (description ? " | " + description : "") } | ||
, 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 | ||
@@ -865,3 +867,3 @@ , void 0 | ||
keys = keys.map(function(key){ | ||
return should.inspect(key); | ||
return i(key); | ||
}); | ||
@@ -871,3 +873,3 @@ var last = keys.pop(); | ||
} else { | ||
str = should.inspect(keys[0]); | ||
str = i(keys[0]); | ||
} | ||
@@ -916,5 +918,5 @@ | ||
code == status | ||
, function(){ return 'expected response code of ' + code + ' ' + should.inspect(statusCodes[code]) | ||
+ ', but got ' + status + ' ' + should.inspect(statusCodes[status]) } | ||
, function(){ return 'expected to not respond with ' + code + ' ' + should.inspect(statusCodes[code]) }); | ||
, function(){ return 'expected response code of ' + code + ' ' + i(statusCodes[code]) | ||
+ ', but got ' + status + ' ' + i(statusCodes[status]) } | ||
, function(){ return 'expected to not respond with ' + code + ' ' + i(statusCodes[code]) }); | ||
@@ -921,0 +923,0 @@ return this; |
{ "name": "should" | ||
, "description": "test framework agnostic BDD-style assertions" | ||
, "version": "2.1.0" | ||
, "version": "2.1.1" | ||
, "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||
@@ -5,0 +5,0 @@ , "repository": { "type": "git", "url": "git://github.com/visionmedia/should.js.git" } |
@@ -225,3 +225,3 @@ # should.js | ||
Assert property exists and has optional value: | ||
Assert property exists and has optional value(compare using `===`): | ||
```javascript | ||
@@ -228,0 +228,0 @@ user.should.have.property('name') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
138685
0.07%3099
0.06%