diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f2ef18f7..bec9a137 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2257,7 +2257,7 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { - function toHaveBeenCalledWith(util) { + function toHaveBeenCalledWith(util, customEqualityTesters) { return { compare: function() { var args = Array.prototype.slice.call(arguments, 0), @@ -2274,7 +2274,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { return result; } - if (util.contains(actual.calls.allArgs(), expectedArgs)) { + if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) { result.pass = true; result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; }; } else { diff --git a/spec/core/matchers/toHaveBeenCalledWithSpec.js b/spec/core/matchers/toHaveBeenCalledWithSpec.js index 1af0a76f..0dd3ad7a 100644 --- a/spec/core/matchers/toHaveBeenCalledWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledWithSpec.js @@ -14,6 +14,20 @@ describe("toHaveBeenCalledWith", function() { expect(result.message()).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was."); }); + it("passes through the custom equality testers", function() { + var util = { + contains: jasmine.createSpy('delegated-contains').and.returnValue(true) + }, + customEqualityTesters = [function() { return true; }], + matcher = j$.matchers.toHaveBeenCalledWith(util, customEqualityTesters), + calledSpy = j$.createSpy('called-spy'); + + calledSpy('a', 'b'); + matcher.compare(calledSpy, 'a', 'b'); + + expect(util.contains).toHaveBeenCalledWith([['a', 'b']], ['a', 'b'], customEqualityTesters); + }); + it("fails when the actual was not called", function() { var util = { contains: jasmine.createSpy('delegated-contains').and.returnValue(false) diff --git a/src/core/matchers/toHaveBeenCalledWith.js b/src/core/matchers/toHaveBeenCalledWith.js index 03b26872..18a6c5b3 100644 --- a/src/core/matchers/toHaveBeenCalledWith.js +++ b/src/core/matchers/toHaveBeenCalledWith.js @@ -1,6 +1,6 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { - function toHaveBeenCalledWith(util) { + function toHaveBeenCalledWith(util, customEqualityTesters) { return { compare: function() { var args = Array.prototype.slice.call(arguments, 0), @@ -17,7 +17,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { return result; } - if (util.contains(actual.calls.allArgs(), expectedArgs)) { + if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) { result.pass = true; result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; }; } else {