Inject a per-runable pretty printer into MatchersUtil
This will allow us to add support for custom object formatters, which will be a per-runable resource like custom matchers, by injecting them into the pretty-printer.
This commit is contained in:
committed by
Steve Gravrock
parent
dec67bd535
commit
1f23f1e4d2
@@ -10,7 +10,7 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
|
||||
* @example
|
||||
* expect(function() { throw new Error('nope'); }).toThrowMatching(function(thrown) { return thrown.message === 'nope'; });
|
||||
*/
|
||||
function toThrowMatching() {
|
||||
function toThrowMatching(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, predicate) {
|
||||
var thrown;
|
||||
@@ -40,14 +40,14 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function thrownDescription(thrown) {
|
||||
if (thrown && thrown.constructor) {
|
||||
return j$.fnNameFor(thrown.constructor) + ' with message ' +
|
||||
j$.pp(thrown.message);
|
||||
} else {
|
||||
return j$.pp(thrown);
|
||||
function thrownDescription(thrown) {
|
||||
if (thrown && thrown.constructor) {
|
||||
return j$.fnNameFor(thrown.constructor) + ' with message ' +
|
||||
matchersUtil.pp(thrown.message);
|
||||
} else {
|
||||
return matchersUtil.pp(thrown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user