guard-jasmine-headless-webkit/lib/guard/jasmine-headless-webkit/runner.rb

38 lines
952 B
Ruby
Raw Normal View History

2011-05-26 14:31:56 +00:00
require 'guard/notifier'
2011-05-24 01:28:01 +00:00
module Guard
class JasmineHeadlessWebkitRunner
class << self
def run(paths = [])
file = Tempfile.new('guard-jasmine-headless-webkit')
file.close
2011-05-26 14:31:56 +00:00
system %{jasmine-headless-webkit --report #{file.path} -c #{paths.join(" ")}}
2011-05-26 14:31:56 +00:00
total, fails, any_console, secs = File.read(file.path).strip.split('/')
2011-05-26 15:26:47 +00:00
Notifier.notify(message(total, fails, secs, any_console == "T"), :title => 'Jasmine results', :image => image(any_console == "T", fails))
2011-05-26 15:26:47 +00:00
fails.to_i
end
private
def message(total, fails, secs, any_console)
"#{total} tests, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
end
def image(any_console, fails)
if any_console
:pending
else
if fails.to_i == 0
:success
else
:failed
end
end
2011-05-24 01:28:01 +00:00
end
end
end
end