From 2c03ffc3c72be83c21c74d55503789bc2c82f0a3 Mon Sep 17 00:00:00 2001 From: Michael Kessler Date: Wed, 10 Apr 2013 14:16:06 +0200 Subject: [PATCH] Fix undefined global logs. (Closes #124) --- CHANGELOG.md | 4 ++++ lib/guard/jasmine/phantomjs/guard-jasmine.coffee | 4 ++-- lib/guard/jasmine/phantomjs/guard-jasmine.js | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5b266c..8489644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Master + +- [#124](https://github.com/netzpirat/guard-jasmine/pull/124): Fix undefined global logs. + ## 1.15.0 - April 8, 2013 - [#123](https://github.com/netzpirat/guard-jasmine/issues/123): Report javascript errors that prevent specs from running. ([@swistak][]) diff --git a/lib/guard/jasmine/phantomjs/guard-jasmine.coffee b/lib/guard/jasmine/phantomjs/guard-jasmine.coffee index 1c83fe9..b3504b3 100644 --- a/lib/guard/jasmine/phantomjs/guard-jasmine.coffee +++ b/lib/guard/jasmine/phantomjs/guard-jasmine.coffee @@ -39,9 +39,9 @@ page.onConsoleMessage = (msg, line, source) -> else if /^SPEC_START: (\d+)$/.test(msg) currentSpecId = Number(RegExp.$1) - logs[currentSpecId] = [] else + logs[currentSpecId] ||= [] logs[currentSpecId].push(msg) # Initialize the page before the JavaScript is run. @@ -68,7 +68,7 @@ page.open options.url, (status) -> phantom.exit() else runnerAvailable = page.evaluate -> window.jasmine - + if runnerAvailable done = -> phantom.exit() waitFor specsReady, done, options.timeout diff --git a/lib/guard/jasmine/phantomjs/guard-jasmine.js b/lib/guard/jasmine/phantomjs/guard-jasmine.js index eefe6d8..68c8be4 100644 --- a/lib/guard/jasmine/phantomjs/guard-jasmine.js +++ b/lib/guard/jasmine/phantomjs/guard-jasmine.js @@ -1,4 +1,3 @@ -// Generated by CoffeeScript 1.3.3 (function() { var currentSpecId, errors, logs, options, page, specsReady, waitFor; @@ -42,9 +41,9 @@ return window.resultReceived = true; }); } else if (/^SPEC_START: (\d+)$/.test(msg)) { - currentSpecId = Number(RegExp.$1); - return logs[currentSpecId] = []; + return currentSpecId = Number(RegExp.$1); } else { + logs[currentSpecId] || (logs[currentSpecId] = []); return logs[currentSpecId].push(msg); } };