Sha256: 47a291ab28cf37328935dec24e0fc7b800c4fb5ac7c75b46c2052f15fbc002f7

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module TestNotifier
  class << self
    attr_accessor :__notifier__
    attr_accessor :default_notifier
  end

  extend self

  NO_NOTIFIERS_MESSAGE = "[TEST NOTIFIER] You have no supported notifiers installed. Please read documentation."

  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!"
  }

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

    notifier.notify(options)
  end

  def notifier
    self.__notifier__ ||= begin
      notifier = TestNotifier::Notifier.supported_notifier_from_name(default_notifier)
      notifier ||= TestNotifier::Notifier.supported_notifiers.first

      STDERR << NO_NOTIFIERS_MESSAGE if notifier == TestNotifier::Notifier::Placebo

      notifier
    end
  end

  autoload :Notifier,   "test_notifier/notifier"
  autoload :Runner,     "test_notifier/runner"
  autoload :Stats,      "test_notifier/stats"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_notifier-0.3.5.rc.2 lib/test_notifier.rb
test_notifier-0.3.5.rc.1 lib/test_notifier.rb