forked from flapjack/flapjack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotifier_filters_spec.rb
52 lines (40 loc) · 1.99 KB
/
notifier_filters_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'applications', 'notifier')
require File.join(File.dirname(__FILE__), '..', 'lib', 'flapjack', 'transports', 'result')
require File.join(File.dirname(__FILE__), 'helpers')
describe "running the notifier" do
before(:all) do
@options = { :notifiers => {:testmailer => {}},
:notifier_directories => [File.join(File.dirname(__FILE__),'notifier-directories', 'spoons')],
:recipients => [{:name => "Spoons McDoom"}],
:transport => {:backend => :mock_transport,
:basedir => File.join(File.dirname(__FILE__), 'transports')},
:persistence => {:backend => :mock_persistence_backend,
:basedir => File.join(File.dirname(__FILE__), 'persistence')},
:filter_directories => [File.join(File.dirname(__FILE__),'test-filters')]
}
end
it "should notify by default" do
@options[:filters] = []
@options[:log] = MockLogger.new
app = Flapjack::Notifier::Application.run(@options)
# processes a MockResult, as defined in spec/transports/mock_transport.rb
app.process_result
app.log.messages.find {|m| m =~ /testmailer notifying/i}.should be_true
end
it "should not notify if any filters fail" do
@options[:filters] = ['blocker']
@options[:log] = MockLogger.new
app = Flapjack::Notifier::Application.run(@options)
# processes a MockResult, as defined in spec/transports/mock_transport.rb
app.process_result
app.log.messages.find {|m| m =~ /testmailer notifying/i}.should be_nil
end
it "should notify if all filters pass" do
@options[:filters] = ['mock']
@options[:log] = MockLogger.new
app = Flapjack::Notifier::Application.run(@options)
# processes a MockResult, as defined in spec/transports/mock_transport.rb
app.process_result
app.log.messages.find {|m| m =~ /testmailer notifying/i}.should be_true
end
end