busterjs/buster-assertions — pull request #6 by malclocke (2012-05-03 08:52:47+00:00)
Title: Change signature of assert.exception().

Allows exceptions messages to be tested against a string or RegExp,
exception type to be tested, or exception to be verified against a user
provided callback.

Examples below with corresponding messages.

assert.exception(function() { throw new Error("foo"); }, TypeError);
// [assert.exception] Expected TypeError but threw Error (foo)

assert.exception(function() { throw new Error("foo"); }, "bar");
// [assert.exception] Expected exception message to match bar but threw Error (foo)

assert.exception(function() { throw new Error("foo"); }, /bar/);
// [assert.exception] Expected exception message to match /bar/ but threw Error (foo)

assert.exception(function() { throw new Error("foo"); }, function(err) { return err.message === "bar"; });
// Expected function (err) { return err.message === "bar"; } to return true for Error (foo)