flapjack 0.6.53 → 0.6.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. data/bin/flapjack +103 -19
  2. data/bin/flapjack-nagios-receiver +166 -52
  3. data/bin/flapper +107 -18
  4. data/etc/flapjack_config.yaml.example +16 -0
  5. data/features/events.feature +63 -0
  6. data/features/steps/events_steps.rb +5 -5
  7. data/features/steps/notifications_steps.rb +8 -6
  8. data/features/steps/time_travel_steps.rb +4 -4
  9. data/features/support/env.rb +1 -2
  10. data/flapjack.gemspec +1 -1
  11. data/lib/flapjack/configuration.rb +11 -13
  12. data/lib/flapjack/coordinator.rb +100 -220
  13. data/lib/flapjack/data/entity_check.rb +2 -2
  14. data/lib/flapjack/data/event.rb +3 -3
  15. data/lib/flapjack/executive.rb +30 -40
  16. data/lib/flapjack/filters/delays.rb +1 -1
  17. data/lib/flapjack/gateways/api.rb +6 -23
  18. data/lib/flapjack/gateways/email.rb +4 -10
  19. data/lib/flapjack/gateways/email/alert.html.haml +0 -5
  20. data/lib/flapjack/gateways/email/alert.text.erb +0 -1
  21. data/lib/flapjack/gateways/jabber.rb +80 -67
  22. data/lib/flapjack/gateways/oobetet.rb +29 -25
  23. data/lib/flapjack/gateways/pagerduty.rb +26 -45
  24. data/lib/flapjack/gateways/sms_messagenet.rb +10 -17
  25. data/lib/flapjack/gateways/web.rb +7 -21
  26. data/lib/flapjack/gateways/web/views/_css.haml +3 -0
  27. data/lib/flapjack/gateways/web/views/check.haml +1 -1
  28. data/lib/flapjack/logger.rb +57 -0
  29. data/lib/flapjack/patches.rb +0 -10
  30. data/lib/flapjack/pikelet.rb +214 -30
  31. data/lib/flapjack/redis_pool.rb +2 -17
  32. data/lib/flapjack/version.rb +1 -1
  33. data/spec/lib/flapjack/coordinator_spec.rb +116 -136
  34. data/spec/lib/flapjack/data/entity_check_spec.rb +3 -3
  35. data/spec/lib/flapjack/executive_spec.rb +33 -34
  36. data/spec/lib/flapjack/gateways/api_spec.rb +4 -2
  37. data/spec/lib/flapjack/gateways/jabber_spec.rb +39 -36
  38. data/spec/lib/flapjack/gateways/oobetet_spec.rb +14 -24
  39. data/spec/lib/flapjack/gateways/pagerduty_spec.rb +43 -45
  40. data/spec/lib/flapjack/gateways/web_spec.rb +42 -35
  41. data/spec/lib/flapjack/logger_spec.rb +32 -0
  42. data/spec/lib/flapjack/pikelet_spec.rb +124 -15
  43. data/spec/lib/flapjack/redis_pool_spec.rb +1 -3
  44. data/spec/spec_helper.rb +34 -1
  45. data/tasks/events.rake +1 -0
  46. data/tmp/create_event_ok.rb +31 -0
  47. data/tmp/create_event_unknown.rb +31 -0
  48. data/tmp/create_events_ok.rb +1 -1
  49. metadata +10 -11
  50. data/bin/flapjack-nagios-receiver-control +0 -15
  51. data/bin/flapper-control +0 -15
  52. data/lib/flapjack/daemonizing.rb +0 -186
  53. data/lib/flapjack/gateways/base.rb +0 -38
@@ -1,35 +1,36 @@
1
1
  require 'spec_helper'
2
2
  require 'flapjack/gateways/web'
3
3
 
4
- # TODO move the rest of the redis operations down to data models, then this
5
- # test won't need read/write redis data
6
-
7
- describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
4
+ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
8
5
 
9
6
  def app
10
7
  Flapjack::Gateways::Web
11
8
  end
12
9
 
13
10
  let(:entity_name) { 'example.com'}
14
- let(:entity_name_esc) { URI.escape(entity_name) }
11
+ let(:entity_name_esc) { CGI.escape(entity_name) }
15
12
  let(:check) { 'ping' }
16
13
 
17
14
  let(:entity) { mock(Flapjack::Data::Entity) }
18
15
  let(:entity_check) { mock(Flapjack::Data::EntityCheck) }
19
16
 
17
+ let(:redis) { mock('redis') }
18
+
20
19
  before(:each) do
21
- Flapjack::RedisPool.should_receive(:new).and_return(@redis)
22
- Flapjack::Gateways::Web.bootstrap(:config => {})
20
+ Flapjack::RedisPool.should_receive(:new).and_return(redis)
21
+ Flapjack::Gateways::Web.instance_variable_set('@config', {})
22
+ Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
23
+ Flapjack::Gateways::Web.start
23
24
  end
24
25
 
25
26
  def expect_stats
26
- @redis.should_receive(:keys).with('*').and_return([])
27
- @redis.should_receive(:zcard).with('failed_checks')
28
- @redis.should_receive(:keys).with('check:*:*').and_return([])
29
- @redis.should_receive(:zscore).with('executive_instances', anything).and_return(Time.now.to_i)
30
- @redis.should_receive(:hgetall).twice.and_return({'all' => '8001', 'ok' => '8002'},
31
- {'all' => '9001', 'ok' => '9002'}) #
32
- @redis.should_receive(:llen).with('events')
27
+ redis.should_receive(:keys).with('*').and_return([])
28
+ redis.should_receive(:zcard).with('failed_checks')
29
+ redis.should_receive(:keys).with('check:*:*').and_return([])
30
+ redis.should_receive(:zscore).with('executive_instances', anything).and_return(Time.now.to_i)
31
+ redis.should_receive(:hgetall).twice.and_return({'all' => '8001', 'ok' => '8002'},
32
+ {'all' => '9001', 'ok' => '9002'})
33
+ redis.should_receive(:llen).with('events')
33
34
  end
34
35
 
35
36
  def expect_entity_check_status(ec)
@@ -49,41 +50,44 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
49
50
  # (for the methods that access redis directly)
50
51
 
51
52
  it "shows a page listing all checks" do
52
- @redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}:states"])
53
+ redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}:states"])
53
54
 
54
55
  expect_stats
55
56
 
57
+ redis.should_receive(:zrange).with("executive_instances", "0", "-1", :withscores => true)
58
+
56
59
  expect_entity_check_status(entity_check)
57
60
 
58
61
  Flapjack::Data::Entity.should_receive(:find_by_name).
59
- with(entity_name, :redis => @redis).and_return(entity)
62
+ with(entity_name, :redis => redis).and_return(entity)
60
63
 
61
64
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
62
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
65
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
63
66
 
64
67
  get '/'
65
68
  last_response.should be_ok
66
69
  end
67
70
 
68
71
  it "shows a page listing failing checks" do
69
- @redis.should_receive(:zrange).with("executive_instances", "0", "-1", :withscores => true)
70
- @redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}:states"])
72
+ redis.should_receive(:zrange).with("executive_instances", "0", "-1", :withscores => true)
73
+ redis.should_receive(:zrange).with('failed_checks', 0, -1).and_return(["#{entity_name}:#{check}:states"])
71
74
 
72
75
  expect_stats
73
76
 
74
77
  expect_entity_check_status(entity_check)
75
78
 
76
79
  Flapjack::Data::Entity.should_receive(:find_by_name).
77
- with(entity_name, :redis => @redis).and_return(entity)
80
+ with(entity_name, :redis => redis).and_return(entity)
78
81
 
79
82
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
80
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
83
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
81
84
  get '/failing'
82
85
  last_response.should be_ok
83
86
  end
84
87
 
85
88
  it "shows a page listing flapjack statistics" do
86
89
  expect_stats
90
+ redis.should_receive(:zrange).with("executive_instances", "0", "-1", :withscores => true)
87
91
 
88
92
  get '/self_stats'
89
93
  last_response.should be_ok
@@ -108,10 +112,10 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
108
112
  entity_check.should_receive(:contacts).and_return([])
109
113
 
110
114
  Flapjack::Data::Entity.should_receive(:find_by_name).
111
- with(entity_name, :redis => @redis).and_return(entity)
115
+ with(entity_name, :redis => redis).and_return(entity)
112
116
 
113
117
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
114
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
118
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
115
119
 
116
120
  get "/check?entity=#{entity_name_esc}&check=ping"
117
121
  last_response.should be_ok
@@ -119,25 +123,28 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
119
123
  end
120
124
 
121
125
  it "returns 404 if an unknown entity is requested" do
126
+ Flapjack::Data::Entity.should_receive(:find_by_name).
127
+ with(entity_name_esc, :redis => redis).and_return(nil)
128
+
122
129
  get "/check?entity=#{entity_name_esc}&check=ping"
123
130
  last_response.should be_not_found
124
131
  end
125
132
 
126
133
  # TODO shouldn't create actual entity record
127
134
  it "returns 404 if no entity check is passed" do
128
- Flapjack::Data::Entity.add({'id' => '5000',
129
- 'name' => entity_name},
130
- :redis => @redis)
135
+ Flapjack::Data::Entity.should_receive(:find_by_name).
136
+ with(entity_name, :redis => redis).and_return(entity)
137
+
131
138
  get "/check?entity=#{entity_name_esc}"
132
139
  last_response.should be_not_found
133
140
  end
134
141
 
135
142
  it "creates an acknowledgement for an entity check" do
136
143
  Flapjack::Data::Entity.should_receive(:find_by_name).
137
- with(entity_name, :redis => @redis).and_return(entity)
144
+ with(entity_name, :redis => redis).and_return(entity)
138
145
 
139
146
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
140
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
147
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
141
148
 
142
149
  entity_check.should_receive(:create_acknowledgement).
143
150
  with(an_instance_of(Hash))
@@ -157,10 +164,10 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
157
164
  ChronicDuration.should_receive(:parse).with('30 minutes').and_return(duration)
158
165
 
159
166
  Flapjack::Data::Entity.should_receive(:find_by_name).
160
- with(entity_name, :redis => @redis).and_return(entity)
167
+ with(entity_name, :redis => redis).and_return(entity)
161
168
 
162
169
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
163
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
170
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
164
171
 
165
172
  entity_check.should_receive(:create_scheduled_maintenance).
166
173
  with(:start_time => start_time.to_i, :duration => duration, :summary => summary)
@@ -176,10 +183,10 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
176
183
  start_time = t - (24 * 60 * 60)
177
184
 
178
185
  Flapjack::Data::Entity.should_receive(:find_by_name).
179
- with(entity_name, :redis => @redis).and_return(entity)
186
+ with(entity_name, :redis => redis).and_return(entity)
180
187
 
181
188
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
182
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
189
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
183
190
 
184
191
  Chronic.should_receive(:parse).with('now').and_return(t)
185
192
 
@@ -197,10 +204,10 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
197
204
  start_time = t - (24 * 60 * 60)
198
205
 
199
206
  Flapjack::Data::Entity.should_receive(:find_by_name).
200
- with(entity_name, :redis => @redis).and_return(entity)
207
+ with(entity_name, :redis => redis).and_return(entity)
201
208
 
202
209
  Flapjack::Data::EntityCheck.should_receive(:for_entity).
203
- with(entity, 'ping', :redis => @redis).and_return(entity_check)
210
+ with(entity, 'ping', :redis => redis).and_return(entity_check)
204
211
 
205
212
  entity_check.should_receive(:delete_scheduled_maintenance).
206
213
  with(:start_time => start_time)
@@ -223,7 +230,7 @@ describe Flapjack::Gateways::Web, :sinatra => true, :redis => true do
223
230
  contact.should_receive(:entities_and_checks).and_return([])
224
231
 
225
232
  Flapjack::Data::Contact.should_receive(:find_by_id).
226
- with('0362', :redis => @redis).and_return(contact)
233
+ with('0362', :redis => redis).and_return(contact)
227
234
 
228
235
  get "/contacts/0362"
229
236
  last_response.should be_ok
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'flapjack/pikelet'
3
+
4
+ describe Flapjack::Logger do
5
+
6
+ # let(:logger) { mock(Log4r::Logger) }
7
+ # let(:stdout_out) { mock('stdout_out') }
8
+ # let(:syslog_out) { mock('syslog_out') }
9
+
10
+ it "creates a log4r logger"
11
+
12
+ it "changes the logging level via config hash"
13
+
14
+ it "passes a log command to its log4r logger"
15
+
16
+ # def setup_logger(type)
17
+ # formatter = mock('Formatter')
18
+ # Log4r::PatternFormatter.should_receive(:new).with(
19
+ # :pattern => "[%l] %d :: #{type} :: %m",
20
+ # :date_pattern => "%Y-%m-%dT%H:%M:%S%z").and_return(formatter)
21
+
22
+ # stdout_out.should_receive(:formatter=).with(formatter)
23
+ # syslog_out.should_receive(:formatter=).with(formatter)
24
+
25
+ # Log4r::StdoutOutputter.should_receive(:new).and_return(stdout_out)
26
+ # Log4r::SyslogOutputter.should_receive(:new).and_return(syslog_out)
27
+ # logger.should_receive(:add).with(stdout_out)
28
+ # logger.should_receive(:add).with(syslog_out)
29
+ # Log4r::Logger.should_receive(:new).and_return(logger)
30
+ # end
31
+
32
+ end
@@ -3,26 +3,135 @@ require 'flapjack/pikelet'
3
3
 
4
4
  describe Flapjack::Pikelet do
5
5
 
6
- let(:stdout) { mock('StdoutOutputter') }
7
- let(:syslogout) { mock('SyslogOutputter') }
8
- let(:logger) { mock('Logger') }
6
+ let(:config) { mock('config') }
7
+ let(:redis_config) { mock('redis_config') }
9
8
 
10
- class Breakfast
11
- include Flapjack::Pikelet
9
+ let(:logger) { mock(Flapjack::Logger) }
10
+
11
+ let(:fiber) { mock(Fiber) }
12
+
13
+ it "creates and starts an executive pikelet" do
14
+ Flapjack::Logger.should_receive(:new).and_return(logger)
15
+
16
+ config.should_receive(:[]).with('logger').and_return(nil)
17
+
18
+ executive = mock('executive')
19
+ executive.should_receive(:start)
20
+ Flapjack::Executive.should_receive(:new).with(:config => config,
21
+ :redis_config => redis_config, :logger => logger).and_return(executive)
22
+
23
+ fiber.should_receive(:resume)
24
+ Fiber.should_receive(:new).and_yield.and_return(fiber)
25
+
26
+ pik = Flapjack::Pikelet.create('executive', :config => config,
27
+ :redis_config => redis_config)
28
+ pik.should be_a(Flapjack::Pikelet::Generic)
29
+ pik.start
12
30
  end
13
31
 
14
- it "should bootstrap an including class" do
15
- Log4r::StdoutOutputter.should_receive(:new).and_return(stdout)
16
- Log4r::SyslogOutputter.should_receive(:new).and_return(syslogout)
17
- logger.should_receive(:add).with(stdout)
18
- logger.should_receive(:add).with(syslogout)
19
- Log4r::Logger.should_receive(:new).and_return(logger)
32
+ it "handles an exception raised by a jabber pikelet" do
33
+ Flapjack::Logger.should_receive(:new).and_return(logger)
34
+ logger.should_receive(:fatal)
35
+
36
+ config.should_receive(:[]).with('logger').and_return(nil)
37
+
38
+ jabber = mock('jabber')
39
+ jabber.should_receive(:start).and_raise(RuntimeError)
40
+ jabber.should_receive(:stop)
41
+ Flapjack::Gateways::Jabber.should_receive(:new).with(:config => config,
42
+ :redis_config => redis_config, :logger => logger).and_return(jabber)
43
+
44
+ fiber.should_receive(:resume)
45
+ Fiber.should_receive(:new).and_yield.and_return(fiber)
46
+
47
+ pik = Flapjack::Pikelet.create('jabber', :config => config,
48
+ :redis_config => redis_config)
49
+ pik.should be_a(Flapjack::Pikelet::Generic)
50
+ pik.start
51
+ end
52
+
53
+ it "creates and starts a resque worker gateway" do
54
+ Flapjack::Logger.should_receive(:new).and_return(logger)
55
+
56
+ config.should_receive(:[]).with('logger').and_return(nil)
57
+ config.should_receive(:[]).with('queue').and_return('email_notif')
58
+
59
+ Flapjack::Gateways::Email.should_receive(:instance_variable_set).
60
+ with('@config', config)
61
+ Flapjack::Gateways::Email.should_receive(:instance_variable_set).
62
+ with('@redis_config', redis_config)
63
+ Flapjack::Gateways::Email.should_receive(:instance_variable_set).
64
+ with('@logger', logger)
65
+
66
+ worker = mock('worker')
67
+ worker.should_receive(:work).with(0.1)
68
+ Flapjack::Gateways::Email.should_receive(:start)
69
+ EM::Resque::Worker.should_receive(:new).with('email_notif').and_return(worker)
70
+
71
+ fiber.should_receive(:resume)
72
+ Fiber.should_receive(:new).and_yield.and_return(fiber)
73
+
74
+ pik = Flapjack::Pikelet.create('email', :config => config,
75
+ :redis_config => redis_config)
76
+ pik.should be_a(Flapjack::Pikelet::Resque)
77
+ pik.start
78
+ end
79
+
80
+ it "handles an exception raised by a resque worker gateway" do
81
+ Flapjack::Logger.should_receive(:new).and_return(logger)
82
+ logger.should_receive(:fatal)
83
+
84
+ config.should_receive(:[]).with('logger').and_return(nil)
85
+ config.should_receive(:[]).with('queue').and_return('email_notif')
86
+
87
+ Flapjack::Gateways::Email.should_receive(:instance_variable_set).
88
+ with('@config', config)
89
+ Flapjack::Gateways::Email.should_receive(:instance_variable_set).
90
+ with('@redis_config', redis_config)
91
+ Flapjack::Gateways::Email.should_receive(:instance_variable_set).
92
+ with('@logger', logger)
93
+
94
+ worker = mock('worker')
95
+ worker.should_receive(:work).with(0.1).and_raise(RuntimeError)
96
+ Flapjack::Gateways::Email.should_receive(:start)
97
+ Flapjack::Gateways::Email.should_receive(:stop)
98
+ EM::Resque::Worker.should_receive(:new).with('email_notif').and_return(worker)
99
+
100
+ fiber.should_receive(:resume)
101
+ Fiber.should_receive(:new).and_yield.and_return(fiber)
102
+
103
+ pik = Flapjack::Pikelet.create('email', :config => config,
104
+ :redis_config => redis_config)
105
+ pik.should be_a(Flapjack::Pikelet::Resque)
106
+ pik.start
107
+ end
108
+
109
+ it "creates a thin server gateway" do
110
+ Flapjack::Logger.should_receive(:new).and_return(logger)
111
+
112
+ config.should_receive(:[]).with('logger').and_return(nil)
113
+ config.should_receive(:[]).with('port').and_return(7654)
114
+
115
+ server = mock('server')
116
+ server.should_receive(:start)
117
+ Thin::Server.should_receive(:new).
118
+ with(/^(?:\d{1,3}\.){3}\d{1,3}$/, 7654,
119
+ Flapjack::Gateways::Web, :signals => false).
120
+ and_return(server)
121
+
122
+ Flapjack::Gateways::Web.should_receive(:instance_variable_set).
123
+ with('@config', config)
124
+ Flapjack::Gateways::Web.should_receive(:instance_variable_set).
125
+ with('@redis_config', redis_config)
126
+ Flapjack::Gateways::Web.should_receive(:instance_variable_set).
127
+ with('@logger', logger)
20
128
 
21
- b = Breakfast.new
22
- b.bootstrap
129
+ Flapjack::Gateways::Web.should_receive(:start)
23
130
 
24
- b.should respond_to(:logger)
25
- b.logger.should equal(logger)
131
+ pik = Flapjack::Pikelet.create('web', :config => config,
132
+ :redis_config => redis_config)
133
+ pik.should be_a(Flapjack::Pikelet::Thin)
134
+ pik.start
26
135
  end
27
136
 
28
137
  end
@@ -3,19 +3,17 @@ require 'flapjack/redis_pool'
3
3
 
4
4
  describe Flapjack::RedisPool do
5
5
 
6
- it "is initialized, and emptied" do
6
+ it "is initialized" do
7
7
  EM.synchrony do
8
8
  redis_count = 3
9
9
 
10
10
  redis_conns = redis_count.times.collect {
11
11
  redis = mock('redis')
12
- redis.should_receive(:quit)
13
12
  redis
14
13
  }
15
14
  ::Redis.should_receive(:new).exactly(redis_count).times.and_return(*redis_conns)
16
15
 
17
16
  frp = Flapjack::RedisPool.new(:size => redis_count)
18
- frp.empty!
19
17
 
20
18
  EM.stop
21
19
  end
@@ -21,6 +21,22 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
21
21
  # in ./support/ and its subdirectories.
22
22
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
23
23
 
24
+ class MockLogger
25
+ attr_accessor :messages
26
+
27
+ def initialize
28
+ @messages = []
29
+ end
30
+
31
+ %w(debug info warn error fatal).each do |level|
32
+ class_eval <<-RUBY
33
+ def #{level}(msg)
34
+ @messages << msg
35
+ end
36
+ RUBY
37
+ end
38
+ end
39
+
24
40
  # This file was generated by the `rspec --init` command. Conventionally, all
25
41
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
26
42
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -38,6 +54,18 @@ RSpec.configure do |config|
38
54
  # --seed 1234
39
55
  config.order = 'random'
40
56
 
57
+ config.before(:each, :logger => true) do
58
+ def test_logger(class_name)
59
+ logger = Log4r::Logger.new(class_name)
60
+ outp = Log4r::FileOutputter.new(class_name,
61
+ :filename => File.join(File.dirname(__FILE__), '..', 'log', 'test.log'))
62
+ outp.formatter = Log4r::PatternFormatter.new(:pattern => "[%l] %d :: #{class_name} :: %m",
63
+ :date_pattern => "%Y-%m-%dT%H:%M:%S%z")
64
+ logger.add(outp)
65
+ logger
66
+ end
67
+ end
68
+
41
69
  config.around(:each, :redis => true) do |example|
42
70
  @redis = ::Redis.new(:db => 14, :driver => :ruby)
43
71
  @redis.flushdb
@@ -45,11 +73,16 @@ RSpec.configure do |config|
45
73
  @redis.quit
46
74
  end
47
75
 
76
+ config.around(:each, :logger => true) do |example|
77
+ @logger = MockLogger.new
78
+ example.run
79
+ @logger.messages.clear
80
+ end
81
+
48
82
  config.after(:each, :time => true) do
49
83
  Delorean.back_to_the_present
50
84
  end
51
85
 
52
86
  config.include HamlViewHelper, :haml_view => true
53
-
54
87
  config.include Rack::Test::Methods, :sinatra => true
55
88
  end