Skip to content

Commit

Permalink
Fix filter Regex (Fixes #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
netzpirat committed Sep 8, 2011
1 parent ba15b1e commit e4e857f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/guard/jasmine/phantomjs/run-jasmine.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ waitFor = (testFx, onReady, timeOutMillis=3000) ->
condition = (if typeof testFx is 'string' then eval testFx else testFx())
else
if not condition
console.log "JasmineResult: #{ JSON.stringify { error: "Timeout requesting Jasmine test runner!" } }"
console.log JSON.stringify { error: "Timeout requesting Jasmine test runner!" }
phantom.exit(1)
else
if typeof onReady is 'string' then eval onReady else onReady()
Expand All @@ -23,7 +23,7 @@ waitFor = (testFx, onReady, timeOutMillis=3000) ->
# Check arguments of the script.
#
if phantom.args.length isnt 1
console.log "JasmineResult: #{ JSON.stringify { error: "Wrong usage of PhantomJS script!" } }"
console.log JSON.stringify { error: "Wrong usage of PhantomJS script!" }
phantom.exit()
else
url = phantom.args[0]
Expand All @@ -33,7 +33,8 @@ page = new WebPage()
# Output the Jasmine test runner result as JSON object.
# Ignore all other calls to console.log
#
page.onConsoleMessage = (msg) -> console.log(RegExp.$1) if /^JasmineResult: (.*)$/.test(msg)
page.onConsoleMessage = (msg) ->
console.log(RegExp.$1) if /^JasmineResult: ([\s\S]*)$/.test(msg)

# Open web page and run the Jasmine test runner
#
Expand All @@ -46,7 +47,9 @@ page.open url, (status) ->

else
# Wait until the Jasmine test is run
waitFor -> page.evaluate -> if document.body.querySelector '.finished-at' then true else false
waitFor ->
page.evaluate ->
if document.body.querySelector '.finished-at' then true else false
, ->
# Jasmine test runner has finished, extract the result from the DOM
page.evaluate ->
Expand Down

0 comments on commit e4e857f

Please sign in to comment.