Permalink
Browse files

Making error constructor checking more lenient.

Matches real world: for example restify's errors do not have a `name` property on their constructor or even their prototype (which is more common).

Bumped version to 1.2.0.
  • Loading branch information...
1 parent b557954 commit 71e23309cae82b367c86a2eb29725122ba5323fc @domenic committed Mar 29, 2012
Showing with 7 additions and 6 deletions.
  1. +6 −5 lib/chai-as-promised.js
  2. +1 −1 package.json
View
@@ -131,14 +131,14 @@
}
function constructorIsGood() {
- return rejectionReason instanceof Constructor && rejectionReason.name === Constructor.name;
+ return rejectionReason instanceof Constructor;
}
var onTransformedFulfilled = function () {
if (!this.negate) {
if (Constructor) {
this.assert(constructorIsGood(),
- "expected " + this.inspect + " to be rejected with " + Constructor.name +
+ "expected " + this.inspect + " to be rejected with " + Constructor.prototype.name +
" but it was rejected with " + chai.inspect(rejectionReason));
}
@@ -155,7 +155,8 @@
if (Constructor) {
this.assert(constructorIsGood(),
null,
- "expected " + this.inspect + " to not be rejected with " + Constructor.name);
+ "expected " + this.inspect + " to not be rejected with " +
+ Constructor.prototype.name);
}
if (message) {
@@ -166,8 +167,8 @@
}
} else {
if (Constructor) {
- this.assert(false, "expected " + this.inspect + " to be rejected with " + Constructor.name +
- " but it was fulfilled");
+ this.assert(false, "expected " + this.inspect + " to be rejected with " +
+ Constructor.prototype.name + " but it was fulfilled");
}
if (message) {
View
@@ -6,7 +6,7 @@
"testing",
"promises"
],
- "version": "1.1.0",
+ "version": "1.2.0",
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",
"repository": {
"type": "git",

0 comments on commit 71e2330

Please sign in to comment.