Sha256: 0378a49f89c5022084e48a1d8d70e6548722120f924f74e108da4782ec1e5ec4

Contents?: true

Size: 1.97 KB

Versions: 24

Compression:

Stored size: 1.97 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'notifier_engine')
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'transports', 'result')
require File.join(File.dirname(__FILE__), 'helpers')

describe "running the notifier" do 
 
  before(:each) do 
  end
 
  it "should complain if no logger has been specified" do 
    lambda {
      n = Flapjack::NotifierEngine.new
    }.should raise_error(RuntimeError)
  end
  
  it "should warn if no notifiers have been specified" do 
    n = Flapjack::NotifierEngine.new(:log => MockLogger.new)
    n.log.messages.last.should =~ /no notifiers/
  end

  it "should log when adding a new notifier" do
    mock_notifier = mock("MockFlapjack::NotifierEngine")
    n = Flapjack::NotifierEngine.new(:log => MockLogger.new, 
                     :notifiers => [mock_notifier])
    n.log.messages.last.should =~ /using the (.+) notifier/
  end

  it "should call notify on each notifier when notifying" do 
    mock_notifier = mock("MockFlapjack::NotifierEngine")
    mock_notifier.should_receive(:notify)

    result = Flapjack::Transport::Result.new(:result => {:check_id => 12345})

    n = Flapjack::NotifierEngine.new(:log => MockLogger.new, 
                                     :notifiers => [mock_notifier])
    n.notify!(:result => result, 
              :event => true, 
              :recipients => [OpenStruct.new({:name => "John Doe"})])
  end

  it "should log notification on each notifier" do 
    mock_notifier = mock("MockFlapjack::NotifierEngine")
    mock_notifier.stub!(:notify)

    result = Flapjack::Transport::Result.new(:result => {:check_id => 12345})

    n = Flapjack::NotifierEngine.new(:log => MockLogger.new, 
                                     :notifiers => [mock_notifier])
    n.notify!(:result => result, 
              :event => true,
              :recipients => [OpenStruct.new({:name => "John Doe"})])
    n.log.messages.last.should =~ /12345/
    n.log.messages.last.should =~ /John Doe/
  end
end


Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
flapjack-0.6.43 spec.old/notifier_spec.rb
flapjack-0.6.42 spec.old/notifier_spec.rb
flapjack-0.6.41 spec.old/notifier_spec.rb
flapjack-0.6.40 spec.old/notifier_spec.rb
flapjack-0.6.39 spec.old/notifier_spec.rb
flapjack-0.6.38 spec.old/notifier_spec.rb
flapjack-0.6.37 spec.old/notifier_spec.rb
flapjack-0.6.36 spec.old/notifier_spec.rb
flapjack-0.6.35 spec.old/notifier_spec.rb
flapjack-0.6.34 spec.old/notifier_spec.rb
flapjack-0.6.33 spec.old/notifier_spec.rb
flapjack-0.6.32 spec.old/notifier_spec.rb
flapjack-0.6.31 spec.old/notifier_spec.rb
flapjack-0.6.30 spec.old/notifier_spec.rb
flapjack-0.6.29 spec.old/notifier_spec.rb
flapjack-0.6.28 spec.old/notifier_spec.rb
flapjack-0.6.27 spec.old/notifier_spec.rb
flapjack-0.6.26 spec.old/notifier_spec.rb
flapjack-0.6.25 spec.old/notifier_spec.rb
flapjack-0.6.24 spec.old/notifier_spec.rb