Added wasNotCalledWith matcher, used argsForCall a bit less

This commit is contained in:
Nathan Wilmes & Davis W. Frank
2009-12-21 11:45:49 -08:00
parent 849a4efda8
commit d90852336f
3 changed files with 40 additions and 8 deletions

View File

@@ -198,12 +198,28 @@ jasmine.Matchers.prototype.wasCalledWith = function() {
}
this.message = function() {
return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall);
if (this.actual.callCount == 0) {
return "Expected spy to have been called with " + jasmine.pp(arguments) + " but it was never called.";
} else {
return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall);
}
};
return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
};
jasmine.Matchers.prototype.wasNotCalledWith = function() {
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
}
this.message = function() {
return "Expected spy not to have been called with " + jasmine.pp(arguments) + " but it was";
};
return !this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
};
/**
* Matcher that checks that the expected item is an element in the actual Array.
*