Sha256: 197dae08fae167abc032820fba0c475bbb7a504c4e26f808682cc0167af7b88f

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require "notifier"

module TestNotifier
  class << self
    attr_accessor :default_notifier, :silence_no_notifier_warning
  end

  extend self

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

  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

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

    notifier
  end

  require "test_notifier/runner"
  require "test_notifier/stats"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_notifier-2.0.1 lib/test_notifier.rb
test_notifier-2.0.0 lib/test_notifier.rb
test_notifier-1.0.1 lib/test_notifier.rb