Sha256: cd1bd4e3862f284dbb9c4a8d42c5fad4fac5123c791aacc2b269e7048715e327

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

require "spec_helper"

describe TestNotifier do
  before { unsupport_all_notifiers }

  it "uses default notifier" do
    allow(Notifier::Growl).to receive(:supported?).and_return(true)
    allow(Notifier::Snarl).to receive(:supported?).and_return(true)
    TestNotifier.default_notifier = :snarl

    expect(TestNotifier.notifier).to eql(Notifier::Snarl)
  end

  it "outputs error message to $stderr when there's no supported notifier" do
    expect(STDERR).to receive(:<<).with(TestNotifier::NO_NOTIFIERS_MESSAGE)
    expect(Notifier::Placebo).to receive(:notify)

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

  it "outputs error message won't display when silence_no_notifier_warning is true" do
    TestNotifier.silence_no_notifier_warning = true

    expect(STDERR).not_to receive(:<<)
    expect(Notifier::Placebo).to receive(:notify)

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

  it "outputs error message won't display when silence_no_notifier_warning is true" do
    TestNotifier.silence_no_notifier_warning = true

    expect(STDERR).not_to receive(:<<)
    expect(Notifier::Placebo).to receive(:notify)

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

  it "sends notification to supported notifier" do
    allow(Notifier::Snarl).to receive(:supported?).and_return(true)
    expect(Notifier::Snarl).to receive(:notify).with({
      :status  => :fail,
      :message => "You have failed!",
      :title   => TestNotifier::TITLES[:fail],
      :image   => TestNotifier::IMAGES[:fail],
      :color   => TestNotifier::COLORS[:fail]
    })

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
test_notifier-2.0.3 spec/test_notifier_spec.rb
test_notifier-2.0.2 spec/test_notifier_spec.rb
test_notifier-2.0.1 spec/test_notifier_spec.rb
test_notifier-2.0.0 spec/test_notifier_spec.rb