Use jasmineToString for printing out complicated matchers

This commit is contained in:
gvanhove
2011-03-14 18:50:08 -07:00
parent 7158fc2426
commit 4f2fcff15a
4 changed files with 49 additions and 10 deletions

View File

@@ -365,7 +365,7 @@ jasmine.Matchers.Any.prototype.matches = function(other) {
return other instanceof this.expectedClass;
};
jasmine.Matchers.Any.prototype.toString = function() {
jasmine.Matchers.Any.prototype.jasmineToString = function() {
return '<jasmine.any(' + this.expectedClass + ')>';
};

View File

@@ -23,10 +23,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
this.emitScalar('null');
} else if (value === jasmine.getGlobal()) {
this.emitScalar('<global>');
} else if (value instanceof jasmine.Matchers.Any) {
this.emitScalar(value.toString());
} else if (value instanceof jasmine.Matchers.ObjectContaining) {
this.emitScalar(value.toString());
} else if (value.hasOwnProperty("jasmineToString")) {
this.emitScalar(value.jasmineToString());
} else if (typeof value === 'string') {
this.emitString(value);
} else if (jasmine.isSpy(value)) {