Skip to content

Commit f9b185a

Browse files
Added quotation marks around string. Issue shouldjs#3. Commit acb49ac
1 parent acb49ac commit f9b185a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ should.Assertion.prototype.rejectedWith = function(message, properties) {
124124
that.fail();
125125
}
126126

127-
var errorMatched = true, errorInfo = '';
127+
var errorMatched = true, errorInfo = '', messageStr;
128128

129129
if('string' == typeof message) {
130130
errorMatched = message == err.message;
@@ -147,7 +147,8 @@ should.Assertion.prototype.rejectedWith = function(message, properties) {
147147

148148
if(!errorMatched) {
149149
if('string' == typeof message || message instanceof RegExp) {
150-
errorInfo = " with a message matching " + message + ", but got '" + err.message + "'";
150+
messageStr = message instanceof RegExp ? message : "'" + message + "'";
151+
errorInfo = " with a message matching " + messageStr + ", but got '" + err.message + "'";
151152
} else if('function' == typeof message) {
152153
errorInfo = " of type " + util.functionName(message) + ", but got " + util.functionName(err.constructor);
153154
}

0 commit comments

Comments
 (0)