Pass sensible arguments in ExpectationResults

This commit is contained in:
ragaskar
2009-10-29 20:33:01 -07:00
parent 328cc89980
commit 827fd1da0e
20 changed files with 1371 additions and 1436 deletions

View File

@@ -536,7 +536,7 @@ jasmine.version_= {
"major": 0,
"minor": 10,
"build": 0,
"revision": 1256870877
"revision": 1256873610
};
/**
* @namespace
@@ -1003,18 +1003,11 @@ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
return result;
};
/**
* Matcher that compares the actual to the expected using ===.
*
* @param expected
*/
jasmine.Matchers.addMatcher = function(matcherName, options) {
jasmine.Matchers.prototype[matcherName] = function () {
jasmine.util.extend(this, options);
var expected = jasmine.util.argsToArray(arguments);
var args = [this.actual].concat(expected);
var matcherArgs = jasmine.util.argsToArray(arguments);
var args = [this.actual].concat(matcherArgs);
var result = options.test.apply(this, args);
var message;
if (!result) {
@@ -1023,7 +1016,7 @@ jasmine.Matchers.addMatcher = function(matcherName, options) {
var expectationResult = new jasmine.ExpectationResult({
matcherName: matcherName,
passed: result,
expected: expected,
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
actual: this.actual,
message: message
});
@@ -1099,7 +1092,7 @@ jasmine.Matchers.addMatcher('toMatch', {
return new RegExp(expected).test(actual);
},
message: function(actual, expected) {
return actual + " does not match the regular expression " + new RegExp(expected).toString();
return jasmine.pp(actual) + " does not match the regular expression " + new RegExp(expected).toString();
}
});
@@ -1113,7 +1106,7 @@ jasmine.Matchers.addMatcher('toNotMatch', {
return !(new RegExp(expected).test(actual));
},
message: function(actual, expected) {
return actual + " should not match " + new RegExp(expected).toString();
return jasmine.pp(actual) + " should not match " + new RegExp(expected).toString();
}
});