diff --git a/guard-jasmine-headless-webkit.gemspec b/guard-jasmine-headless-webkit.gemspec index be72bf4..a03fd30 100644 --- a/guard-jasmine-headless-webkit.gemspec +++ b/guard-jasmine-headless-webkit.gemspec @@ -20,5 +20,5 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_dependency 'guard', '>= 0.2.2' - s.add_dependency 'jasmine-headless-webkit' + s.add_dependency 'jasmine-headless-webkit', '>= 0.2.2' end diff --git a/lib/guard/jasmine-headless-webkit/runner.rb b/lib/guard/jasmine-headless-webkit/runner.rb index 06a8ac2..ca2c79c 100644 --- a/lib/guard/jasmine-headless-webkit/runner.rb +++ b/lib/guard/jasmine-headless-webkit/runner.rb @@ -1,32 +1,17 @@ require 'guard/notifier' -require 'open3' module Guard class JasmineHeadlessWebkitRunner class << self def run(paths = []) - lines = [""] + file = Tempfile.new('guard-jasmine-headless-webkit') + file.close - Open3.popen3(%{jasmine-headless-webkit -c #{paths.join(" ")}}) do |stdin, stdout, stderr| - stdin.close - stderr.close - while !stdout.eof? - $stdout.print (char = stdout.getc) - $stdout.flush + system %{jasmine-headless-webkit --report #{file.path} -c #{paths.join(" ")}} - if char.chr == "\n" - lines << "" - else - lines.last << char.chr - end - end - end + total, fails, any_console, secs = File.read(file.path).strip.split('/') - total, fails, secs = lines[-2].scan(%r{.* (\d+) tests, (\d+) failures, (.+) secs..*}).flatten - - any_console = lines.any? { |line| line['[console] '] } - - Notifier.notify(message(total, fails, secs, any_console), :title => 'Jasmine results', :image => image(any_console, fails)) + Notifier.notify(message(total, fails, secs, any_console == "T"), :title => 'Jasmine results', :image => image(any_console == "T", fails)) fails.to_i end