From 1c6c7a475494610e4ae4dc475033fe968ff257c1 Mon Sep 17 00:00:00 2001 From: "Bailey, John (Nightwing)" Date: Mon, 21 Jan 2013 14:49:47 -0800 Subject: [PATCH 1/2] FIX: When an error is thrown in the block function, catch it and resolve the complete (invoke complete). This solves an issue where a thrown error will never trigger the complete function. --- lib/jasmine.async.js | 9 +++++++-- lib/jasmine.async.min.js | 4 ++-- src/jasmine.async.js | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/jasmine.async.js b/lib/jasmine.async.js index fb54f88..1a3f9cc 100644 --- a/lib/jasmine.async.js +++ b/lib/jasmine.async.js @@ -1,5 +1,5 @@ // Jasmine.Async, v0.1.0 -// Copyright (c)2012 Muted Solutions, LLC. All Rights Reserved. +// Copyright (c)2013 Muted Solutions, LLC. All Rights Reserved. // Distributed under MIT license // http://github.com/derickbailey/jasmine.async this.AsyncSpec = (function(global){ @@ -13,7 +13,12 @@ this.AsyncSpec = (function(global){ var complete = function(){ done = true; }; runs(function(){ - block(complete); + try{ + block(complete); + } catch ( error ){ + complete(); + throw error; + } }); waitsFor(function(){ diff --git a/lib/jasmine.async.min.js b/lib/jasmine.async.min.js index 1694f7d..3afa4bb 100644 --- a/lib/jasmine.async.min.js +++ b/lib/jasmine.async.min.js @@ -1,5 +1,5 @@ // Jasmine.Async, v0.1.0 -// Copyright (c)2012 Muted Solutions, LLC. All Rights Reserved. +// Copyright (c)2013 Muted Solutions, LLC. All Rights Reserved. // Distributed under MIT license // http://github.com/derickbailey/jasmine.async -this.AsyncSpec=function(a){function b(a){return function(){var b=!1,c=function(){b=!0};runs(function(){a(c)}),waitsFor(function(){return b})}}function c(a){this.spec=a}return c.prototype.beforeEach=function(a){this.spec.beforeEach(b(a))},c.prototype.afterEach=function(a){this.spec.afterEach(b(a))},c.prototype.it=function(c,d){a.it(c,b(d))},c}(this); \ No newline at end of file +this.AsyncSpec=function(e){function t(e){return function(){var t=!1,n=function(){t=!0};runs(function(){try{e(n)}catch(t){throw n(),t}}),waitsFor(function(){return t})}}function n(e){this.spec=e}return n.prototype.beforeEach=function(e){this.spec.beforeEach(t(e))},n.prototype.afterEach=function(e){this.spec.afterEach(t(e))},n.prototype.it=function(n,r){e.it(n,t(r))},n}(this); \ No newline at end of file diff --git a/src/jasmine.async.js b/src/jasmine.async.js index efffffe..e25fb67 100644 --- a/src/jasmine.async.js +++ b/src/jasmine.async.js @@ -9,7 +9,12 @@ this.AsyncSpec = (function(global){ var complete = function(){ done = true; }; runs(function(){ - block(complete); + try{ + block(complete); + } catch ( error ){ + complete(); + throw error; + } }); waitsFor(function(){ From 7074fc627642f00aea6785c70ccbd9eb23193438 Mon Sep 17 00:00:00 2001 From: "Bailey, John (Nightwing)" Date: Wed, 23 Jan 2013 14:41:34 -0800 Subject: [PATCH 2/2] FIX: Persist behavior of Jasmine for Specs by supplying the context to the block function. This allows the developer to reference the spec within the block. With the Jasmine it function, the block supplied gets the context of spec (or rather is the context of spec) --- lib/jasmine.async.js | 2 +- lib/jasmine.async.min.js | 2 +- src/jasmine.async.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jasmine.async.js b/lib/jasmine.async.js index 1a3f9cc..fba4699 100644 --- a/lib/jasmine.async.js +++ b/lib/jasmine.async.js @@ -14,7 +14,7 @@ this.AsyncSpec = (function(global){ runs(function(){ try{ - block(complete); + block.call(this,complete); } catch ( error ){ complete(); throw error; diff --git a/lib/jasmine.async.min.js b/lib/jasmine.async.min.js index 3afa4bb..78e409f 100644 --- a/lib/jasmine.async.min.js +++ b/lib/jasmine.async.min.js @@ -2,4 +2,4 @@ // Copyright (c)2013 Muted Solutions, LLC. All Rights Reserved. // Distributed under MIT license // http://github.com/derickbailey/jasmine.async -this.AsyncSpec=function(e){function t(e){return function(){var t=!1,n=function(){t=!0};runs(function(){try{e(n)}catch(t){throw n(),t}}),waitsFor(function(){return t})}}function n(e){this.spec=e}return n.prototype.beforeEach=function(e){this.spec.beforeEach(t(e))},n.prototype.afterEach=function(e){this.spec.afterEach(t(e))},n.prototype.it=function(n,r){e.it(n,t(r))},n}(this); \ No newline at end of file +this.AsyncSpec=function(e){function t(e){return function(){var t=!1,n=function(){t=!0};runs(function(){try{e.call(this,n)}catch(t){throw n(),t}}),waitsFor(function(){return t})}}function n(e){this.spec=e}return n.prototype.beforeEach=function(e){this.spec.beforeEach(t(e))},n.prototype.afterEach=function(e){this.spec.afterEach(t(e))},n.prototype.it=function(n,r){e.it(n,t(r))},n}(this); \ No newline at end of file diff --git a/src/jasmine.async.js b/src/jasmine.async.js index e25fb67..5500b7d 100644 --- a/src/jasmine.async.js +++ b/src/jasmine.async.js @@ -10,7 +10,7 @@ this.AsyncSpec = (function(global){ runs(function(){ try{ - block(complete); + block.call(this,complete); } catch ( error ){ complete(); throw error;