diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f8cf1cdd..4e2c19da 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -3138,8 +3138,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { var args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; - if(!expected){ - throw new Error('Expected times failed is required as an argument.'); + if (!j$.isNumber_(expected)){ + throw new Error('The expected times failed is a required argument and must be a number.'); } actual = args[0]; @@ -3156,7 +3156,6 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { return toHaveBeenCalledTimes; }; - getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { function toHaveBeenCalledWith(util, customEqualityTesters) { diff --git a/spec/core/matchers/toHaveBeenCalledTimesSpec.js b/spec/core/matchers/toHaveBeenCalledTimesSpec.js index 3acef36e..55a4a3ba 100644 --- a/spec/core/matchers/toHaveBeenCalledTimesSpec.js +++ b/spec/core/matchers/toHaveBeenCalledTimesSpec.js @@ -1,4 +1,11 @@ describe("toHaveBeenCalledTimes", function() { + it("passes when the actual 0 matches the expected 0 ", function () { + var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + calledSpy = jasmineUnderTest.createSpy('called-spy'), + result; + result = matcher.compare(calledSpy, 0); + expect(result.pass).toBeTruthy(); + }); it("passes when the actual matches the expected", function() { var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), calledSpy = jasmineUnderTest.createSpy('called-spy'), @@ -17,7 +24,7 @@ describe("toHaveBeenCalledTimes", function() { spy(); expect(function() { matcher.compare(spy); - }).toThrowError('Expected times failed is required as an argument.'); + }).toThrowError('The expected times failed is a required argument and must be a number.'); }); it("fails when the actual was called less than the expected", function() { @@ -60,7 +67,6 @@ describe("toHaveBeenCalledTimes", function() { spy(); result = matcher.compare(spy, 1); - expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.'); }); @@ -74,7 +80,6 @@ describe("toHaveBeenCalledTimes", function() { spy(); result = matcher.compare(spy, 2); - expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.'); }); }); diff --git a/src/core/matchers/toHaveBeenCalledTimes..js b/src/core/matchers/toHaveBeenCalledTimes.js similarity index 87% rename from src/core/matchers/toHaveBeenCalledTimes..js rename to src/core/matchers/toHaveBeenCalledTimes.js index b59cc4f4..597968fd 100644 --- a/src/core/matchers/toHaveBeenCalledTimes..js +++ b/src/core/matchers/toHaveBeenCalledTimes.js @@ -10,8 +10,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { var args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; - if(!expected){ - throw new Error('Expected times failed is required as an argument.'); + if (!j$.isNumber_(expected)){ + throw new Error('The expected times failed is a required argument and must be a number.'); } actual = args[0]; @@ -27,4 +27,4 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { } return toHaveBeenCalledTimes; -}; +}; \ No newline at end of file