lib/autotest_notification.rb in autotest-notification-2.3.3 vs lib/autotest_notification.rb in autotest-notification-2.3.4
- old
+ new
@@ -1,12 +1,12 @@
require "autotest"
$:.unshift(File.dirname(__FILE__))
module AutotestNotification
-
- VERSION = '2.3.2'
-
+
+ VERSION = '2.3.4'
+
class Config
class << self
attr_reader :images_directory
attr_accessor :success_image, :fail_image, :pending_image, :expiration_in_seconds
@@ -25,18 +25,19 @@
self.expiration_in_seconds = 3
end
Autotest.add_hook :ran_command do |at|
+ autotest = at #make it work with autotest 4.5.5
lines = autotest.results.map { |s| s.gsub(/(\e.*?m|\n)/, '') } # remove escape sequences
lines.reject! { |line| !line.match(/\d+\s+(seed|example|test|scenario|step)s?/) } # isolate result numbers
-
+
lines.each do |line|
%w{ test assertion error example pending failure }.each { |x| instance_variable_set "@#{x}s", line[/(\d+) #{x}/, 1].to_i }
end
-
- if @tests
+
+ if @tests && (@tests != 0) #make it work with autotest 4.5.5 and RSpec 2.6.0
code = 31 if @failures > 0 || @errors > 0
msg = unit_test_message(@tests, @assertions, @failures, @errors)
elsif @examples
code = (@failures > 0) ? 31 : (@pendings > 0) ? 33 : 32
msg = rspec_message(@examples, @failures, @pendings)
@@ -99,9 +100,11 @@
when /darwin/
Mac.notify(title, msg, img, total, failures, priority)
when /cygwin/
Cygwin.notify(title, msg, img, total, failures)
when /mswin/
+ Windows.notify(title, msg, img)
+ when /mingw/
Windows.notify(title, msg, img)
end
end
def pluralize(text, number)