Module: TestNotifier

Extended by:
TestNotifier
Included in:
TestNotifier
Defined in:
lib/test_notifier.rb,
lib/test_notifier/stats.rb,
lib/test_notifier/runner.rb,
lib/test_notifier/version.rb

Defined Under Namespace

Modules: Runner, Version Classes: Stats

Constant Summary collapse

NO_NOTIFIERS_MESSAGE =
"[TEST NOTIFIER] You have no supported notifiers installed. Please read documentation.\n"
IMAGES =
{
  :fail    => File.dirname(__FILE__) + "/../resources/fail.png",
  :error   => File.dirname(__FILE__) + "/../resources/error.png",
  :success => File.dirname(__FILE__) + "/../resources/success.png"
}
TITLES =
{
  :fail    => "Failed!",
  :success => "Passed!",
  :error   => "Error!"
}
COLORS =
{
  :fail    => "orange",
  :success => "green",
  :error   => "red"
}

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.default_notifierObject

Returns the value of attribute default_notifier.



5
6
7
# File 'lib/test_notifier.rb', line 5

def default_notifier
  @default_notifier
end

.silence_no_notifier_warningObject

Returns the value of attribute silence_no_notifier_warning.



5
6
7
# File 'lib/test_notifier.rb', line 5

def silence_no_notifier_warning
  @silence_no_notifier_warning
end

Instance Method Details

#notifierObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/test_notifier.rb', line 40

def notifier
  Notifier.default_notifier = default_notifier
  notifier = Notifier.notifier

  if notifier == Notifier::Placebo && !silence_no_notifier_warning
    STDERR << NO_NOTIFIERS_MESSAGE
  end

  notifier
end

#notify(options) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/test_notifier.rb', line 30

def notify(options)
  options.merge!({
    :title => TITLES[options[:status]],
    :image => IMAGES[options[:status]],
    :color => COLORS[options[:status]]
  })

  notifier.notify(options)
end