From b525313cdb8dd52aa86b32523b90cc30f9d4fc71 Mon Sep 17 00:00:00 2001 From: Sheel Choksi Date: Sat, 4 Jan 2014 23:08:21 -0800 Subject: [PATCH] Make the check for pending spec exception work for values that don't have toString --- lib/jasmine-core/jasmine.js | 2 +- spec/core/SpecSpec.js | 4 ++++ src/core/Spec.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 92b0158b..d30bef49 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -366,7 +366,7 @@ getJasmineRequireObj().Spec = function(j$) { Spec.pendingSpecExceptionMessage = "=> marked Pending"; Spec.isPendingSpecException = function(e) { - return e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1; + return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); }; return Spec; diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index b0186dee..b1d67fe1 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -20,6 +20,10 @@ describe("Spec", function() { expect(j$.Spec.isPendingSpecException(e)).toBe(false); }); + it("#isPendingSpecException returns false for thrown values that don't have toString", function() { + expect(j$.Spec.isPendingSpecException(void 0)).toBe(false); + }); + it("delegates execution to a QueueRunner", function() { var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), spec = new j$.Spec({ diff --git a/src/core/Spec.js b/src/core/Spec.js index e8f48539..462a0f02 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -141,7 +141,7 @@ getJasmineRequireObj().Spec = function(j$) { Spec.pendingSpecExceptionMessage = "=> marked Pending"; Spec.isPendingSpecException = function(e) { - return e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1; + return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); }; return Spec;