Sha256: 726e325bacbd85bd83f4336a10185745e378042015b38eb3f12ebd3dd246aca3

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require "notifier"

module TestNotifier
  class << self
    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!"
  }

  COLORS = {
    :fail    => "orange",
    :success => "green",
    :error   => "red"
  }

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

    notifier.notify(options)
  end

  def notifier
    Notifier.default_notifier = default_notifier
    notifier = Notifier.notifier
    STDERR << NO_NOTIFIERS_MESSAGE if notifier == Notifier::Placebo
    notifier
  end

  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.4.0 lib/test_notifier.rb
test_notifier-0.3.6 lib/test_notifier.rb