Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b9f035c6d8
Fetching contributors…

Cannot retrieve contributors at this time

file 20 lines (19 sloc) 0.782 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/ruby
module Autotest::Notify
  def self.notify title, msg, img, pri='low', time=3000
    `notify-send -i #{img} -u #{pri} -t #{time} '#{title}' '#{msg}'`
  end

  Autotest.add_hook :ran_command do |autotest|
    results = [autotest.results].flatten.join("\n")
    output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
    folder = "~/."
    return if output =~ /0\sexamples/
    if output =~ /[1-9]\d*\sfailures?/
      notify "Test failed!", "#{output}", folder+"rails_fail.png", 'critical', 10000
    elsif output =~ /[1-9]\d*\spending?/
      notify "Test succeeded with pending!", "#{output}", folder+"rails_pending.png", 'normal', 10000
    else
      notify "Test succeeded!", "#{output}", folder+"rails_ok.png"
    end
  end
end
Something went wrong with that request. Please try again.