Skip to content

Commit

Permalink
Merge pull request Automattic#26 from amasad/fix-25
Browse files Browse the repository at this point in the history
Use isRegExp in Assertion::throwException. Fix Automattic#25
  • Loading branch information
rauchg committed Jun 4, 2013
2 parents f3f2138 + 5ff06c7 commit b1547ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@
try {
this.obj();
} catch (e) {
if ('function' == typeof fn) {
fn(e);
} else if ('object' == typeof fn) {
if (isRegExp(fn)) {
var subject = 'string' == typeof e ? e : e.message;
if (not) {
expect(subject).to.not.match(fn);
} else {
expect(subject).to.match(fn);
}
} else if ('function' == typeof fn) {
fn(e);
}
thrown = true;
}

if ('object' == typeof fn && not) {
if (isRegExp(fn) && not) {
// in the presence of a matcher, ensure the `not` only applies to
// the matching.
this.flags.not = false;
Expand Down

0 comments on commit b1547ed

Please sign in to comment.