diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 6fb31080..eb2b160d 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -5829,18 +5829,18 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { expectedArgs = args.slice(1); if (!j$.isSpy(actual)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.')); + throw new Error(getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.')); } var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) { - return ' ' + j$.pp(argsForCall); + return ' ' + util.pp(argsForCall); }); if (actual.calls.count() === 1 && util.contains(actual.calls.allArgs(), expectedArgs)) { return { pass: true, message: 'Expected spy ' + actual.and.identity + ' to have been called 0 times, multiple times, or once, but with arguments different from:\n' - + ' ' + j$.pp(expectedArgs) + '\n' + + ' ' + util.pp(expectedArgs) + '\n' + 'But the actual call was:\n' + prettyPrintedCalls.join(',\n') + '.\n\n' }; @@ -5868,7 +5868,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { return { pass: false, message: 'Expected spy ' + actual.and.identity + ' to have been called only once, and with given args:\n' - + ' ' + j$.pp(expectedArgs) + '\n' + + ' ' + util.pp(expectedArgs) + '\n' + butString() }; } diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 090bb54c..ae7cd0d6 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1992,6 +1992,7 @@ describe("Env integration", function() { exception; env.describe("a suite", function () { + env.it('a spec'); try { env.setSpecProperty('a prop', 'val'); } catch(e) { diff --git a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js index be0e95bc..d79711a5 100644 --- a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js @@ -1,7 +1,8 @@ describe("toHaveBeenCalledOnceWith", function () { it("passes when the actual was called only once and with matching parameters", function () { - var util = jasmineUnderTest.matchersUtil, + var pp = jasmineUnderTest.makePrettyPrinter(), + util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), calledSpy = new jasmineUnderTest.Spy('called-spy'), result; @@ -27,7 +28,8 @@ describe("toHaveBeenCalledOnceWith", function () { }); it("fails when the actual was never called", function () { - var util = jasmineUnderTest.matchersUtil, + var pp = jasmineUnderTest.makePrettyPrinter(), + util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), calledSpy = new jasmineUnderTest.Spy('called-spy'), result; @@ -39,7 +41,8 @@ describe("toHaveBeenCalledOnceWith", function () { }); it("fails when the actual was called once with different parameters", function () { - var util = jasmineUnderTest.matchersUtil, + var pp = jasmineUnderTest.makePrettyPrinter(), + util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), calledSpy = new jasmineUnderTest.Spy('called-spy'), result; @@ -52,7 +55,8 @@ describe("toHaveBeenCalledOnceWith", function () { }); it("fails when the actual was called multiple times with expected parameters", function () { - var util = jasmineUnderTest.matchersUtil, + var pp = jasmineUnderTest.makePrettyPrinter(), + util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), calledSpy = new jasmineUnderTest.Spy('called-spy'), result; @@ -66,7 +70,8 @@ describe("toHaveBeenCalledOnceWith", function () { }); it("fails when the actual was called multiple times (one of them - with expected parameters)", function () { - var util = jasmineUnderTest.matchersUtil, + var pp = jasmineUnderTest.makePrettyPrinter(), + util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), calledSpy = new jasmineUnderTest.Spy('called-spy'), result; @@ -80,7 +85,9 @@ describe("toHaveBeenCalledOnceWith", function () { }); it("throws an exception when the actual is not a spy", function () { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(), + var pp = jasmineUnderTest.makePrettyPrinter(), + util = new jasmineUnderTest.MatchersUtil({ pp: pp }), + matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), fn = function () { }; expect(function () { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./); diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js index d7be3782..2cd607f8 100644 --- a/src/core/matchers/toHaveBeenCalledOnceWith.js +++ b/src/core/matchers/toHaveBeenCalledOnceWith.js @@ -19,18 +19,18 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { expectedArgs = args.slice(1); if (!j$.isSpy(actual)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.')); + throw new Error(getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.')); } var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) { - return ' ' + j$.pp(argsForCall); + return ' ' + util.pp(argsForCall); }); if (actual.calls.count() === 1 && util.contains(actual.calls.allArgs(), expectedArgs)) { return { pass: true, message: 'Expected spy ' + actual.and.identity + ' to have been called 0 times, multiple times, or once, but with arguments different from:\n' - + ' ' + j$.pp(expectedArgs) + '\n' + + ' ' + util.pp(expectedArgs) + '\n' + 'But the actual call was:\n' + prettyPrintedCalls.join(',\n') + '.\n\n' }; @@ -58,7 +58,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { return { pass: false, message: 'Expected spy ' + actual.and.identity + ' to have been called only once, and with given args:\n' - + ' ' + j$.pp(expectedArgs) + '\n' + + ' ' + util.pp(expectedArgs) + '\n' + butString() }; }