Fix wasCalledWith matcher.

This commit is contained in:
Christian Williams 2009-11-12 15:03:55 -05:00
parent 3b92b9bb79
commit 98e86817bf
2 changed files with 23 additions and 21 deletions

View File

@ -535,7 +535,8 @@ describe("jasmine.Matchers", function() {
expect(match(TestClass.someFunction).wasNotCalled()).toEqual(false); expect(match(TestClass.someFunction).wasNotCalled()).toEqual(false);
}); });
it('should return true if it was called with the expected args', function() { describe("wasCalledWith", function() {
it('wasCalledWith should return true if it was called with the expected args', function() {
TestClass.someFunction('a', 'b', 'c'); TestClass.someFunction('a', 'b', 'c');
expect(match(TestClass.someFunction).wasCalledWith('a', 'b', 'c')).toEqual(true); expect(match(TestClass.someFunction).wasCalledWith('a', 'b', 'c')).toEqual(true);
}); });
@ -560,6 +561,7 @@ describe("jasmine.Matchers", function() {
}); });
}); });
}); });
});
describe("wasCalledWith to build an ExpectationResult", function () { describe("wasCalledWith to build an ExpectationResult", function () {
var TestClass; var TestClass;

View File

@ -224,7 +224,7 @@ jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.matcherFn_('wasCalle
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
} }
return this.env.contains_(this.actual.argsForCall, arguments); return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
}, },
message: function() { message: function() {
return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + this.actual.argsForCall; return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + this.actual.argsForCall;