diff --git a/spec/notifier_application_spec.rb b/spec/notifier_application_spec.rb index 2401772b1..8b2655546 100644 --- a/spec/notifier_application_spec.rb +++ b/spec/notifier_application_spec.rb @@ -9,6 +9,7 @@ it "should have a simple interface to start the notifier" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :persistence => {:backend => :mock_persistence_backend, :basedir => File.join(File.dirname(__FILE__), 'persistence')} } @@ -17,6 +18,7 @@ it "should log when loading a notifier" do options = { :notifiers => {:testmailer => {}}, + :filters => [], :log => MockLogger.new, :notifier_directories => [File.join(File.dirname(__FILE__),'notifier-directories', 'spoons')], :persistence => {:backend => :mock_persistence_backend, @@ -27,6 +29,7 @@ it "should warn if a specified notifier doesn't exist" do options = { :notifiers => {:nonexistant => {}}, + :filters => [], :log => MockLogger.new, :persistence => {:backend => :mock_persistence_backend, :basedir => File.join(File.dirname(__FILE__), 'persistence')} } @@ -36,6 +39,7 @@ it "should give precedence to notifiers in user-specified notifier directories" do options = { :notifiers => {:testmailer => {}}, + :filters => [], :log => MockLogger.new, :notifier_directories => [File.join(File.dirname(__FILE__),'notifier-directories', 'spoons')], :persistence => {:backend => :mock_persistence_backend, @@ -50,6 +54,7 @@ it "should setup recipients from a list" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :recipients => [{:name => "Spoons McDoom"}], :persistence => {:backend => :mock_persistence_backend, @@ -65,6 +70,7 @@ it "should use beanstalkd as the default transport" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :persistence => {:backend => :mock_persistence_backend, :basedir => File.join(File.dirname(__FILE__), 'persistence')} } @@ -74,6 +80,7 @@ it "should use a transport as specified in options" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :transport => {:backend => :beanstalkd}, :persistence => {:backend => :mock_persistence_backend, @@ -84,6 +91,7 @@ it "should error if the specified transport doesn't exist" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :transport => {:backend => :nonexistant} } lambda { @@ -100,6 +108,7 @@ # options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :transport => {:backend => :mock_transport, :basedir => File.join(File.dirname(__FILE__), 'transports')}, @@ -129,6 +138,7 @@ # options = { :notifiers => {}, + :filters => ['ok'], :log => MockLogger.new, :transport => {:backend => :mock_transport, :basedir => File.join(File.dirname(__FILE__), 'transports')}, @@ -158,6 +168,7 @@ # options = { :notifiers => {}, + :filters => ['any_parents_failed'], :log => MockLogger.new, :transport => {:backend => :mock_transport, :basedir => File.join(File.dirname(__FILE__), 'transports')}, @@ -188,6 +199,7 @@ it "should load a persistence backend as specified in options" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :persistence => {:backend => :mock_persistence_backend, :basedir => File.join(File.dirname(__FILE__), 'persistence')} } @@ -197,6 +209,7 @@ it "should raise if the specified persistence backend doesn't exist" do options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :persistence => {:backend => :nonexistant} } lambda { diff --git a/spec/notifier_spec.rb b/spec/notifier_spec.rb index 47bfb5c6d..3b205661d 100644 --- a/spec/notifier_spec.rb +++ b/spec/notifier_spec.rb @@ -13,12 +13,6 @@ }.should raise_error(RuntimeError) end - it "should have a blank recipients list if none specified" do - n = Flapjack::NotifierEngine.new(:log => MockLogger.new) - n.recipients.should_not be_nil - n.recipients.size.should == 0 - 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/ @@ -38,9 +32,10 @@ result = Flapjack::Transport::Result.new(:result => {:check_id => 12345}) n = Flapjack::NotifierEngine.new(:log => MockLogger.new, - :notifiers => [mock_notifier], - :recipients => [OpenStruct.new({:name => "John Doe"})]) - n.notify!(:result => result, :event => true) + :notifiers => [mock_notifier]) + n.notify!(:result => result, + :event => true, + :recipients => [OpenStruct.new({:name => "John Doe"})]) end it "should log notification on each notifier" do @@ -50,9 +45,10 @@ result = Flapjack::Transport::Result.new(:result => {:check_id => 12345}) n = Flapjack::NotifierEngine.new(:log => MockLogger.new, - :notifiers => [mock_notifier], - :recipients => [OpenStruct.new({:name => "John Doe"})]) - n.notify!(:result => result, :event => true) + :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 diff --git a/spec/transports/beanstalkd_spec.rb b/spec/transports/beanstalkd_spec.rb index 2fd7a2dee..41b902ad8 100644 --- a/spec/transports/beanstalkd_spec.rb +++ b/spec/transports/beanstalkd_spec.rb @@ -10,7 +10,9 @@ @beanstalk = Beanstalk::Connection.new('localhost:11300', 'results') rescue => e # give helpful error messages to people unfamiliar with the test suite + puts puts "You need to have an instance of beanstalkd running locally to run these tests!" + puts raise end }.should_not raise_error @@ -24,6 +26,7 @@ end options = { :notifiers => {}, + :filters => [], :log => MockLogger.new, :transport => {:backend => :beanstalkd}, :persistence => {:backend => :mock_persistence_backend,