Sha256: de8a0436421a027ee8d28d5690c5a34558fcdfc71398ffd6c6f88f2f131a9531

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require "test_helper"

class TestNotifierTest < Test::Unit::TestCase
  def setup
    TestNotifier.__notifier__ = nil
    unsupport_all_notifiers
  end

  test "return default notifier when is set" do
    TestNotifier.default_notifier = :osd_cat
    TestNotifier::Notifier::OsdCat.expects(:supported?).returns(true)

    assert_equal TestNotifier::Notifier::OsdCat, TestNotifier.notifier
  end

  test "return next available notifier when default notifier is not supported" do
    TestNotifier.default_notifier = :osd_cat
    TestNotifier::Notifier::Snarl.expects(:supported?).returns(true)

    assert_equal TestNotifier::Notifier::Snarl, TestNotifier.notifier
  end

  test "output error message to $stderr when there's no supported notifier" do
    STDERR.expects(:<<).with(TestNotifier::NO_NOTIFIERS_MESSAGE).once
    TestNotifier::Notifier::Placebo.expects(:supported?).returns(true)
    TestNotifier::Notifier::Placebo.expects(:notify).once
    TestNotifier.notify :status => :fail, :message => "You have failed!"
  end

  test "send notification to supported notifier" do
    TestNotifier::Notifier::Snarl.expects(:supported?).returns(true)
    TestNotifier::Notifier::Snarl.expects(:notify).with({
      :status  => :fail,
      :message => "You have failed!",
      :title   => TestNotifier::TITLES[:fail],
      :image   => TestNotifier::IMAGES[:fail]
    })

    TestNotifier.notify :status => :fail, :message => "You have failed!"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_notifier-0.3.5.rc.2 test/test_notifier_test.rb
test_notifier-0.3.5.rc.1 test/test_notifier_test.rb