Class: Guard::MinitestNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/minitest/notifier.rb

Class Method Summary collapse

Class Method Details

.guard_image(failure_count, skip_count) ⇒ Object

failed | pending (skip) | success



19
20
21
22
23
24
25
26
27
# File 'lib/guard/minitest/notifier.rb', line 19

def self.guard_image(failure_count, skip_count)
  icon = if failure_count > 0
    :failed
  elsif skip_count > 0
    :pending
  else
    :success
  end
end

.guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/guard/minitest/notifier.rb', line 7

def self.guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
  message = "#{test_count} examples, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors"
  if skip_count > 0
    message << " (#{skip_count} skips)"
  end
  if test_count && assertion_count
    message << "\nin %.6f seconds, %.4f tests/s, %.4f assertions/s." % [duration, test_count / duration, assertion_count / duration]
  end
  message
end

.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration) ⇒ Object



29
30
31
32
33
34
# File 'lib/guard/minitest/notifier.rb', line 29

def self.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration)
  message = guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
  image   = guard_image(failure_count + error_count, skip_count)

  ::Guard::Notifier.notify(message, :title => 'MiniTest results', :image => image) if notify?
end

.notify?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/guard/minitest/notifier.rb', line 36

def self.notify?
  ENV['GUARD_NOTIFY'] && ENV['GUARD_NOTIFY'] == 'true'
end