Sha256: e49aaee7c29be7f99ed65a01237d9bec9f8dfc7907804ab55be56a39a49f256e

Contents?: true

Size: 959 Bytes

Versions: 16

Compression:

Stored size: 959 Bytes

Contents

module Autotest::Notify
  def self.notify(title, message, priority='critical')
    icon = if priority == 'critical'
      'dialog-error'
    else
      'dialog-information'
    end
    system "notify-send -u #{priority} -t 10000 -i #{icon} '#{title}' '#{message.inspect}'"
  end

  Autotest.add_hook :red do |at|
    tests = 0
    assertions = 0
    failures = 0
    errors = 0
    at.results.scan(/(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/) do |t, a, f, e|
      tests += t.to_i
      assertions += a.to_i
      failures += f.to_i
      errors += e.to_i
    end
    message = "%d tests, %d assertions, %d failures, %d errors" % 
      [tests, assertions, failures, errors]
    notify("Tests Failed", message)
  end

  Autotest.add_hook :green do |at|
    notify("Tests Passed", "Outstanding tests passed", 'low') if at.tainted
  end

  Autotest.add_hook :all do |at|_hook
    notify("autotest", "Tests have fully passed", 'low')
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
grosser-autotest-4.0.3 lib/autotest/notify.rb
grosser-autotest-4.0.4 lib/autotest/notify.rb
ryanbriones-ZenTest-3.11.1 lib/autotest/notify.rb
ZenTest-3.6.1 lib/autotest/notify.rb
ZenTest-3.7.0 lib/autotest/notify.rb
ZenTest-3.7.1 lib/autotest/notify.rb
ZenTest-3.7.2 lib/autotest/notify.rb
ZenTest-3.8.0 lib/autotest/notify.rb
ZenTest-3.9.0 lib/autotest/notify.rb
ZenTest-3.9.1 lib/autotest/notify.rb
ZenTest-3.9.2 lib/autotest/notify.rb
ZenTest-3.9.3 lib/autotest/notify.rb
ZenTest-3.10.0 lib/autotest/notify.rb
ZenTest-3.11.0 lib/autotest/notify.rb
ZenTest-3.11.1 lib/autotest/notify.rb
ZenTest-4.0.0 lib/autotest/notify.rb