flapjack 0.7.35 → 0.8.0

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 (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -1
  3. data/Gemfile +3 -4
  4. data/Guardfile +1 -1
  5. data/README.md +38 -19
  6. data/Rakefile +1 -3
  7. data/etc/flapjack_config.yaml.example +11 -1
  8. data/features/steps/cli_steps.rb +3 -3
  9. data/features/steps/events_steps.rb +7 -6
  10. data/features/steps/flapjack-netsaint-parser_steps.rb +8 -8
  11. data/features/steps/notifications_steps.rb +10 -10
  12. data/features/steps/packaging-lintian_steps.rb +5 -9
  13. data/features/steps/time_travel_steps.rb +1 -1
  14. data/flapjack.gemspec +4 -3
  15. data/lib/flapjack/data/contact.rb +78 -6
  16. data/lib/flapjack/data/entity.rb +11 -2
  17. data/lib/flapjack/data/notification_rule.rb +67 -59
  18. data/lib/flapjack/data/semaphore.rb +44 -0
  19. data/lib/flapjack/gateways/api.rb +24 -28
  20. data/lib/flapjack/gateways/api/contact_methods.rb +1 -2
  21. data/lib/flapjack/gateways/api/entity_methods.rb +3 -3
  22. data/lib/flapjack/gateways/jsonapi.rb +249 -0
  23. data/lib/flapjack/gateways/jsonapi/contact_methods.rb +544 -0
  24. data/lib/flapjack/gateways/jsonapi/entity_check_presenter.rb +217 -0
  25. data/lib/flapjack/gateways/jsonapi/entity_methods.rb +350 -0
  26. data/lib/flapjack/gateways/jsonapi/entity_presenter.rb +75 -0
  27. data/lib/flapjack/gateways/jsonapi/rack/json_params_parser.rb +32 -0
  28. data/lib/flapjack/gateways/web.rb +78 -12
  29. data/lib/flapjack/gateways/web/public/css/bootstrap-theme.css +397 -0
  30. data/lib/flapjack/gateways/web/public/css/bootstrap-theme.min.css +7 -0
  31. data/lib/flapjack/gateways/web/public/css/bootstrap.css +7118 -0
  32. data/lib/flapjack/gateways/web/public/css/bootstrap.min.css +6 -8
  33. data/lib/flapjack/gateways/web/public/css/font-awesome.css +1338 -0
  34. data/lib/flapjack/gateways/web/public/css/font-awesome.min.css +4 -0
  35. data/lib/flapjack/gateways/web/public/css/screen.css +80 -0
  36. data/lib/flapjack/gateways/web/public/css/select2-bootstrap.css +87 -0
  37. data/lib/flapjack/gateways/web/public/css/select2.css +615 -0
  38. data/lib/flapjack/gateways/web/public/fonts/FontAwesome.otf +0 -0
  39. data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.eot +0 -0
  40. data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.svg +414 -0
  41. data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.ttf +0 -0
  42. data/lib/flapjack/gateways/web/public/fonts/fontawesome-webfont.woff +0 -0
  43. data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.eot +0 -0
  44. data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.svg +229 -0
  45. data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  46. data/lib/flapjack/gateways/web/public/fonts/glyphicons-halflings-regular.woff +0 -0
  47. data/lib/flapjack/gateways/web/public/img/flapjack-2013-notext-transparent-300-300.png +0 -0
  48. data/lib/flapjack/gateways/web/public/img/select2.png +0 -0
  49. data/lib/flapjack/gateways/web/public/img/select2x2.png +0 -0
  50. data/lib/flapjack/gateways/web/public/js/backbone-min.js +2 -0
  51. data/lib/flapjack/gateways/web/public/js/backbone.js +1581 -0
  52. data/lib/flapjack/gateways/web/public/js/backbone.jsonapi.js +75 -0
  53. data/lib/flapjack/gateways/web/public/js/bootstrap.js +2276 -0
  54. data/lib/flapjack/gateways/web/public/js/contacts.js +225 -0
  55. data/lib/flapjack/gateways/web/public/js/jquery-1.10.2.js +9789 -0
  56. data/lib/flapjack/gateways/web/public/js/jquery-1.10.2.min.js +6 -0
  57. data/lib/flapjack/gateways/web/public/js/select2.js +3255 -0
  58. data/lib/flapjack/gateways/web/public/js/select2.min.js +22 -0
  59. data/lib/flapjack/gateways/web/public/js/underscore-min.js +6 -0
  60. data/lib/flapjack/gateways/web/public/js/underscore.js +1276 -0
  61. data/lib/flapjack/gateways/web/views/check.html.erb +423 -193
  62. data/lib/flapjack/gateways/web/views/checks.html.erb +51 -71
  63. data/lib/flapjack/gateways/web/views/contact.html.erb +142 -164
  64. data/lib/flapjack/gateways/web/views/contacts.html.erb +20 -40
  65. data/lib/flapjack/gateways/web/views/edit_contacts.html.erb +83 -0
  66. data/lib/flapjack/gateways/web/views/entities.html.erb +18 -37
  67. data/lib/flapjack/gateways/web/views/entity.html.erb +46 -65
  68. data/lib/flapjack/gateways/web/views/index.html.erb +6 -27
  69. data/lib/flapjack/gateways/web/views/layout.erb +95 -0
  70. data/lib/flapjack/gateways/web/views/self_stats.html.erb +100 -114
  71. data/lib/flapjack/pikelet.rb +4 -2
  72. data/lib/flapjack/version.rb +1 -1
  73. data/spec/lib/flapjack/coordinator_spec.rb +120 -120
  74. data/spec/lib/flapjack/data/contact_spec.rb +66 -58
  75. data/spec/lib/flapjack/data/entity_check_spec.rb +179 -179
  76. data/spec/lib/flapjack/data/entity_spec.rb +71 -71
  77. data/spec/lib/flapjack/data/event_spec.rb +34 -30
  78. data/spec/lib/flapjack/data/message_spec.rb +6 -6
  79. data/spec/lib/flapjack/data/notification_rule_spec.rb +24 -24
  80. data/spec/lib/flapjack/data/notification_spec.rb +19 -19
  81. data/spec/lib/flapjack/data/semaphore_spec.rb +24 -0
  82. data/spec/lib/flapjack/data/tag_spec.rb +11 -10
  83. data/spec/lib/flapjack/gateways/api/contact_methods_spec.rb +201 -201
  84. data/spec/lib/flapjack/gateways/api/entity_check_presenter_spec.rb +55 -55
  85. data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +257 -257
  86. data/spec/lib/flapjack/gateways/api/entity_presenter_spec.rb +26 -26
  87. data/spec/lib/flapjack/gateways/api_spec.rb +1 -1
  88. data/spec/lib/flapjack/gateways/email_spec.rb +4 -4
  89. data/spec/lib/flapjack/gateways/jabber_spec.rb +77 -77
  90. data/spec/lib/flapjack/gateways/jsonapi/contact_methods_spec.rb +830 -0
  91. data/spec/lib/flapjack/gateways/jsonapi/entity_check_presenter_spec.rb +211 -0
  92. data/spec/lib/flapjack/gateways/jsonapi/entity_methods_spec.rb +863 -0
  93. data/spec/lib/flapjack/gateways/jsonapi/entity_presenter_spec.rb +108 -0
  94. data/spec/lib/flapjack/gateways/jsonapi_spec.rb +8 -0
  95. data/spec/lib/flapjack/gateways/oobetet_spec.rb +35 -35
  96. data/spec/lib/flapjack/gateways/pagerduty_spec.rb +40 -40
  97. data/spec/lib/flapjack/gateways/sms_messagenet_spec.rb +3 -3
  98. data/spec/lib/flapjack/gateways/web/views/check.html.erb_spec.rb +1 -1
  99. data/spec/lib/flapjack/gateways/web/views/contact.html.erb_spec.rb +5 -5
  100. data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +1 -1
  101. data/spec/lib/flapjack/gateways/web_spec.rb +73 -74
  102. data/spec/lib/flapjack/logger_spec.rb +13 -13
  103. data/spec/lib/flapjack/pikelet_spec.rb +33 -33
  104. data/spec/lib/flapjack/processor_spec.rb +22 -22
  105. data/spec/lib/flapjack/redis_pool_spec.rb +1 -1
  106. data/spec/lib/flapjack/utility_spec.rb +12 -12
  107. data/spec/spec_helper.rb +9 -9
  108. data/spec/support/erb_view_helper.rb +4 -0
  109. metadata +107 -96
  110. data/lib/flapjack/gateways/web/public/css/flapjack.css +0 -49
  111. data/lib/flapjack/gateways/web/views/_css.html.erb +0 -42
  112. data/lib/flapjack/gateways/web/views/_foot.html.erb +0 -3
  113. data/lib/flapjack/gateways/web/views/_head.html.erb +0 -5
  114. data/lib/flapjack/gateways/web/views/_nav.html.erb +0 -10
@@ -20,6 +20,7 @@ require 'thin'
20
20
  require 'flapjack/notifier'
21
21
  require 'flapjack/processor'
22
22
  require 'flapjack/gateways/api'
23
+ require 'flapjack/gateways/jsonapi'
23
24
  require 'flapjack/gateways/jabber'
24
25
  require 'flapjack/gateways/oobetet'
25
26
  require 'flapjack/gateways/pagerduty'
@@ -216,8 +217,9 @@ module Flapjack
216
217
 
217
218
  class Thin < Flapjack::Pikelet::Base
218
219
 
219
- PIKELET_TYPES = {'web' => Flapjack::Gateways::Web,
220
- 'api' => Flapjack::Gateways::API}
220
+ PIKELET_TYPES = {'web' => Flapjack::Gateways::Web,
221
+ 'api' => Flapjack::Gateways::API,
222
+ 'jsonapi' => Flapjack::Gateways::JSONAPI}
221
223
 
222
224
  def self.create(type, opts = {})
223
225
  ::Thin::Logging.silent = true
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.7.35"
4
+ VERSION = "0.8.0"
5
5
  end
@@ -12,30 +12,30 @@ describe Flapjack::Coordinator do
12
12
  let!(:time) { Time.now }
13
13
 
14
14
  it "starts and stops a pikelet" do
15
- Flapjack::Logger.should_receive(:new).and_return(logger)
15
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
16
16
 
17
17
  cfg = {'processor' => {'enabled' => true}}
18
- EM.should_receive(:synchrony).and_yield
19
- config.should_receive(:for_redis).and_return({})
20
- config.should_receive(:all).twice.and_return(cfg)
18
+ expect(EM).to receive(:synchrony).and_yield
19
+ expect(config).to receive(:for_redis).and_return({})
20
+ expect(config).to receive(:all).twice.and_return(cfg)
21
21
 
22
22
  processor = double('processor')
23
- processor.should_receive(:start)
24
- processor.should_receive(:stop)
25
- processor.should_receive(:update_status)
26
- processor.should_receive(:status).exactly(3).times.and_return('stopped')
23
+ expect(processor).to receive(:start)
24
+ expect(processor).to receive(:stop)
25
+ expect(processor).to receive(:update_status)
26
+ expect(processor).to receive(:status).exactly(3).times.and_return('stopped')
27
27
 
28
- Time.should_receive(:now).and_return(time)
28
+ expect(Time).to receive(:now).and_return(time)
29
29
 
30
30
  fc = Flapjack::Coordinator.new(config)
31
- Flapjack::Pikelet.should_receive(:create).with('processor',
31
+ expect(Flapjack::Pikelet).to receive(:create).with('processor',
32
32
  :config => cfg['processor'], :redis_config => {}, :boot_time => time, :coordinator => fc).
33
33
  and_return(processor)
34
34
 
35
- fiber.should_receive(:resume)
36
- Fiber.should_receive(:new).and_yield.and_return(fiber)
35
+ expect(fiber).to receive(:resume)
36
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
37
37
 
38
- EM.should_receive(:stop)
38
+ expect(EM).to receive(:stop)
39
39
 
40
40
  # Syslog.should_receive(:opened?).and_return(true)
41
41
  # Syslog.should_receive(:close)
@@ -45,31 +45,31 @@ describe Flapjack::Coordinator do
45
45
  end
46
46
 
47
47
  it "handles an exception raised by a pikelet and shuts down" do
48
- Flapjack::Logger.should_receive(:new).and_return(logger)
49
- logger.should_receive(:fatal)
48
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
49
+ expect(logger).to receive(:fatal)
50
50
 
51
51
  cfg = {'processor' => {'enabled' => true}}
52
- EM.should_receive(:synchrony).and_yield
53
- config.should_receive(:for_redis).and_return({})
54
- config.should_receive(:all).twice.and_return(cfg)
52
+ expect(EM).to receive(:synchrony).and_yield
53
+ expect(config).to receive(:for_redis).and_return({})
54
+ expect(config).to receive(:all).twice.and_return(cfg)
55
55
 
56
56
  processor = double('processor')
57
- processor.should_receive(:start).and_raise(RuntimeError)
58
- processor.should_receive(:stop)
59
- processor.should_receive(:update_status)
60
- processor.should_receive(:status).exactly(3).times.and_return('stopped')
57
+ expect(processor).to receive(:start).and_raise(RuntimeError)
58
+ expect(processor).to receive(:stop)
59
+ expect(processor).to receive(:update_status)
60
+ expect(processor).to receive(:status).exactly(3).times.and_return('stopped')
61
61
 
62
- Time.should_receive(:now).and_return(time)
62
+ expect(Time).to receive(:now).and_return(time)
63
63
 
64
64
  fc = Flapjack::Coordinator.new(config)
65
- Flapjack::Pikelet.should_receive(:create).with('processor',
65
+ expect(Flapjack::Pikelet).to receive(:create).with('processor',
66
66
  :config => cfg['processor'], :redis_config => {}, :boot_time => time, :coordinator => fc)
67
67
  .and_return(processor)
68
68
 
69
- fiber.should_receive(:resume)
70
- Fiber.should_receive(:new).and_yield.and_return(fiber)
69
+ expect(fiber).to receive(:resume)
70
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
71
71
 
72
- EM.should_receive(:stop)
72
+ expect(EM).to receive(:stop)
73
73
 
74
74
  # Syslog.should_receive(:opened?).and_return(true)
75
75
  # Syslog.should_receive(:close)
@@ -80,36 +80,36 @@ describe Flapjack::Coordinator do
80
80
 
81
81
  it "loads an old executive pikelet config block with no new data" do
82
82
  cfg = {'executive' => {'enabled' => true}}
83
- EM.should_receive(:synchrony).and_yield
84
- config.should_receive(:for_redis).and_return({})
85
- config.should_receive(:all).twice.and_return(cfg)
83
+ expect(EM).to receive(:synchrony).and_yield
84
+ expect(config).to receive(:for_redis).and_return({})
85
+ expect(config).to receive(:all).twice.and_return(cfg)
86
86
 
87
87
  processor = double('processor')
88
- processor.should_receive(:start)
89
- processor.should_receive(:stop)
90
- processor.should_receive(:update_status)
91
- processor.should_receive(:status).exactly(3).times.and_return('stopped')
88
+ expect(processor).to receive(:start)
89
+ expect(processor).to receive(:stop)
90
+ expect(processor).to receive(:update_status)
91
+ expect(processor).to receive(:status).exactly(3).times.and_return('stopped')
92
92
 
93
93
  notifier = double('processor')
94
- notifier.should_receive(:start)
95
- notifier.should_receive(:stop)
96
- notifier.should_receive(:update_status)
97
- notifier.should_receive(:status).exactly(3).times.and_return('stopped')
94
+ expect(notifier).to receive(:start)
95
+ expect(notifier).to receive(:stop)
96
+ expect(notifier).to receive(:update_status)
97
+ expect(notifier).to receive(:status).exactly(3).times.and_return('stopped')
98
98
 
99
- Time.should_receive(:now).and_return(time)
99
+ expect(Time).to receive(:now).and_return(time)
100
100
 
101
101
  fc = Flapjack::Coordinator.new(config)
102
- Flapjack::Pikelet.should_receive(:create).with('processor',
102
+ expect(Flapjack::Pikelet).to receive(:create).with('processor',
103
103
  :config => cfg['executive'], :redis_config => {}, :boot_time => time, :coordinator => fc).
104
104
  and_return(processor)
105
- Flapjack::Pikelet.should_receive(:create).with('notifier',
105
+ expect(Flapjack::Pikelet).to receive(:create).with('notifier',
106
106
  :config => cfg['executive'], :redis_config => {}, :boot_time => time, :coordinator => fc).
107
107
  and_return(notifier)
108
108
 
109
- fiber.should_receive(:resume)
110
- Fiber.should_receive(:new).and_yield.and_return(fiber)
109
+ expect(fiber).to receive(:resume)
110
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
111
111
 
112
- EM.should_receive(:stop)
112
+ expect(EM).to receive(:stop)
113
113
 
114
114
  # Syslog.should_receive(:opened?).and_return(true)
115
115
  # Syslog.should_receive(:close)
@@ -123,28 +123,28 @@ describe Flapjack::Coordinator do
123
123
  'processor' => {'foo' => 'bar'},
124
124
  'notifier' => {'enabled' => false}
125
125
  }
126
- EM.should_receive(:synchrony).and_yield
127
- config.should_receive(:for_redis).and_return({})
128
- config.should_receive(:all).twice.and_return(cfg)
126
+ expect(EM).to receive(:synchrony).and_yield
127
+ expect(config).to receive(:for_redis).and_return({})
128
+ expect(config).to receive(:all).twice.and_return(cfg)
129
129
 
130
130
  processor = double('processor')
131
- processor.should_receive(:start)
132
- processor.should_receive(:stop)
133
- processor.should_receive(:update_status)
134
- processor.should_receive(:status).exactly(3).times.and_return('stopped')
131
+ expect(processor).to receive(:start)
132
+ expect(processor).to receive(:stop)
133
+ expect(processor).to receive(:update_status)
134
+ expect(processor).to receive(:status).exactly(3).times.and_return('stopped')
135
135
 
136
- Time.should_receive(:now).and_return(time)
136
+ expect(Time).to receive(:now).and_return(time)
137
137
 
138
138
  fc = Flapjack::Coordinator.new(config)
139
- Flapjack::Pikelet.should_receive(:create).with('processor',
139
+ expect(Flapjack::Pikelet).to receive(:create).with('processor',
140
140
  :config => cfg['executive'].merge(cfg['processor']),
141
141
  :redis_config => {}, :boot_time => time, :coordinator => fc).
142
142
  and_return(processor)
143
143
 
144
- fiber.should_receive(:resume)
145
- Fiber.should_receive(:new).and_yield.and_return(fiber)
144
+ expect(fiber).to receive(:resume)
145
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
146
146
 
147
- EM.should_receive(:stop)
147
+ expect(EM).to receive(:stop)
148
148
 
149
149
  # Syslog.should_receive(:opened?).and_return(true)
150
150
  # Syslog.should_receive(:close)
@@ -154,44 +154,44 @@ describe Flapjack::Coordinator do
154
154
  end
155
155
 
156
156
  it "traps system signals and shuts down" do
157
- Flapjack::Logger.should_receive(:new).and_return(logger)
157
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
158
158
 
159
- RbConfig::CONFIG.should_receive(:[]).with('host_os').and_return('darwin12.0.0')
159
+ expect(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('darwin12.0.0')
160
160
 
161
- Kernel.should_receive(:trap).with('INT').and_yield
162
- Kernel.should_receive(:trap).with('TERM').and_yield
163
- Kernel.should_receive(:trap).with('QUIT').and_yield
164
- Kernel.should_receive(:trap).with('HUP').and_yield
161
+ expect(Kernel).to receive(:trap).with('INT').and_yield
162
+ expect(Kernel).to receive(:trap).with('TERM').and_yield
163
+ expect(Kernel).to receive(:trap).with('QUIT').and_yield
164
+ expect(Kernel).to receive(:trap).with('HUP').and_yield
165
165
 
166
- config.should_receive(:all).and_return({})
167
- config.should_receive(:for_redis).and_return({})
166
+ expect(config).to receive(:all).and_return({})
167
+ expect(config).to receive(:for_redis).and_return({})
168
168
  fc = Flapjack::Coordinator.new(config)
169
- fc.should_receive(:stop).exactly(3).times
170
- fc.should_receive(:reload)
169
+ expect(fc).to receive(:stop).exactly(3).times
170
+ expect(fc).to receive(:reload)
171
171
 
172
172
  fc.send(:setup_signals)
173
173
  end
174
174
 
175
175
  it "only traps two system signals on Windows" do
176
- Flapjack::Logger.should_receive(:new).and_return(logger)
176
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
177
177
 
178
- RbConfig::CONFIG.should_receive(:[]).with('host_os').and_return('mswin')
178
+ expect(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('mswin')
179
179
 
180
- Kernel.should_receive(:trap).with('INT').and_yield
181
- Kernel.should_receive(:trap).with('TERM').and_yield
182
- Kernel.should_not_receive(:trap).with('QUIT')
183
- Kernel.should_not_receive(:trap).with('HUP')
180
+ expect(Kernel).to receive(:trap).with('INT').and_yield
181
+ expect(Kernel).to receive(:trap).with('TERM').and_yield
182
+ expect(Kernel).not_to receive(:trap).with('QUIT')
183
+ expect(Kernel).not_to receive(:trap).with('HUP')
184
184
 
185
- config.should_receive(:all).and_return({})
186
- config.should_receive(:for_redis).and_return({})
185
+ expect(config).to receive(:all).and_return({})
186
+ expect(config).to receive(:for_redis).and_return({})
187
187
  fc = Flapjack::Coordinator.new(config)
188
- fc.should_receive(:stop).twice
188
+ expect(fc).to receive(:stop).twice
189
189
 
190
190
  fc.send(:setup_signals)
191
191
  end
192
192
 
193
193
  it "stops one pikelet and starts another on reload" do
194
- Flapjack::Logger.should_receive(:new).and_return(logger)
194
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
195
195
 
196
196
  old_cfg = {'processor' => {'enabled' => true}}
197
197
  new_cfg = {'gateways' => {'jabber' => {'enabled' => true}}}
@@ -199,42 +199,42 @@ describe Flapjack::Coordinator do
199
199
  new_config = double('new_config')
200
200
  filename = double('filename')
201
201
 
202
- config.should_receive(:all).twice.and_return(old_cfg)
203
- config.should_receive(:filename).and_return(filename)
202
+ expect(config).to receive(:all).twice.and_return(old_cfg)
203
+ expect(config).to receive(:filename).and_return(filename)
204
204
 
205
- Flapjack::Configuration.should_receive(:new).and_return(new_config)
206
- new_config.should_receive(:load).with(filename)
207
- new_config.should_receive(:all).and_return(new_cfg)
205
+ expect(Flapjack::Configuration).to receive(:new).and_return(new_config)
206
+ expect(new_config).to receive(:load).with(filename)
207
+ expect(new_config).to receive(:all).and_return(new_cfg)
208
208
 
209
209
  processor = double('processor')
210
- processor.should_receive(:type).twice.and_return('processor')
211
- processor.should_receive(:stop)
212
- processor.should_receive(:update_status)
213
- processor.should_receive(:status).exactly(3).times.and_return('stopped')
210
+ expect(processor).to receive(:type).twice.and_return('processor')
211
+ expect(processor).to receive(:stop)
212
+ expect(processor).to receive(:update_status)
213
+ expect(processor).to receive(:status).exactly(3).times.and_return('stopped')
214
214
 
215
- config.should_receive(:for_redis).and_return({})
215
+ expect(config).to receive(:for_redis).and_return({})
216
216
  fc = Flapjack::Coordinator.new(config)
217
217
 
218
218
  jabber = double('jabber')
219
- Flapjack::Pikelet.should_receive(:create).
219
+ expect(Flapjack::Pikelet).to receive(:create).
220
220
  with('jabber', :config => {"enabled" => true}, :redis_config => {},
221
221
  :boot_time => time, :coordinator => fc).
222
222
  and_return(jabber)
223
- jabber.should_receive(:start)
223
+ expect(jabber).to receive(:start)
224
224
 
225
- fiber.should_receive(:resume)
226
- Fiber.should_receive(:new).and_yield.and_return(fiber)
225
+ expect(fiber).to receive(:resume)
226
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
227
227
 
228
228
  fc.instance_variable_set('@boot_time', time)
229
229
  fc.instance_variable_set('@pikelets', [processor])
230
230
  fc.reload
231
- fc.instance_variable_get('@pikelets').should == [jabber]
231
+ expect(fc.instance_variable_get('@pikelets')).to eq([jabber])
232
232
 
233
233
 
234
234
  end
235
235
 
236
236
  it "reloads a pikelet config without restarting it" do
237
- Flapjack::Logger.should_receive(:new).and_return(logger)
237
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
238
238
 
239
239
  old_cfg = {'processor' => {'enabled' => true, 'foo' => 'bar'}}
240
240
  new_cfg = {'processor' => {'enabled' => true, 'foo' => 'baz'}}
@@ -242,29 +242,29 @@ describe Flapjack::Coordinator do
242
242
  new_config = double('new_config')
243
243
  filename = double('filename')
244
244
 
245
- config.should_receive(:all).twice.and_return(old_cfg)
246
- config.should_receive(:filename).and_return(filename)
245
+ expect(config).to receive(:all).twice.and_return(old_cfg)
246
+ expect(config).to receive(:filename).and_return(filename)
247
247
 
248
- Flapjack::Configuration.should_receive(:new).and_return(new_config)
249
- new_config.should_receive(:load).with(filename)
250
- new_config.should_receive(:all).and_return(new_cfg)
248
+ expect(Flapjack::Configuration).to receive(:new).and_return(new_config)
249
+ expect(new_config).to receive(:load).with(filename)
250
+ expect(new_config).to receive(:all).and_return(new_cfg)
251
251
 
252
252
  processor = double('processor')
253
- processor.should_not_receive(:start)
254
- processor.should_receive(:type).exactly(3).times.and_return('processor')
255
- processor.should_receive(:reload).with(new_cfg['processor']).and_return(true)
256
- processor.should_not_receive(:stop)
253
+ expect(processor).not_to receive(:start)
254
+ expect(processor).to receive(:type).exactly(3).times.and_return('processor')
255
+ expect(processor).to receive(:reload).with(new_cfg['processor']).and_return(true)
256
+ expect(processor).not_to receive(:stop)
257
257
 
258
- config.should_receive(:for_redis).and_return({})
258
+ expect(config).to receive(:for_redis).and_return({})
259
259
  fc = Flapjack::Coordinator.new(config)
260
260
  fc.instance_variable_set('@boot_time', time)
261
261
  fc.instance_variable_set('@pikelets', [processor])
262
262
  fc.reload
263
- fc.instance_variable_get('@pikelets').should == [processor]
263
+ expect(fc.instance_variable_get('@pikelets')).to eq([processor])
264
264
  end
265
265
 
266
266
  it "reloads a pikelet config while restarting it" do
267
- Flapjack::Logger.should_receive(:new).and_return(logger)
267
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
268
268
 
269
269
  old_cfg = {'processor' => {'enabled' => true, 'foo' => 'bar'}}
270
270
  new_cfg = {'processor' => {'enabled' => true, 'baz' => 'qux'}}
@@ -272,30 +272,30 @@ describe Flapjack::Coordinator do
272
272
  new_config = double('new_config')
273
273
  filename = double('filename')
274
274
 
275
- config.should_receive(:all).twice.and_return(old_cfg)
276
- config.should_receive(:filename).and_return(filename)
275
+ expect(config).to receive(:all).twice.and_return(old_cfg)
276
+ expect(config).to receive(:filename).and_return(filename)
277
277
 
278
- Flapjack::Configuration.should_receive(:new).and_return(new_config)
279
- new_config.should_receive(:load).with(filename)
280
- new_config.should_receive(:all).and_return(new_cfg)
278
+ expect(Flapjack::Configuration).to receive(:new).and_return(new_config)
279
+ expect(new_config).to receive(:load).with(filename)
280
+ expect(new_config).to receive(:all).and_return(new_cfg)
281
281
 
282
282
  processor = double('processor')
283
- processor.should_receive(:type).exactly(5).times.and_return('processor')
284
- processor.should_receive(:reload).with(new_cfg['processor']).and_return(false)
285
- processor.should_receive(:stop)
286
- processor.should_receive(:update_status)
287
- processor.should_receive(:status).exactly(3).times.and_return('stopped')
283
+ expect(processor).to receive(:type).exactly(5).times.and_return('processor')
284
+ expect(processor).to receive(:reload).with(new_cfg['processor']).and_return(false)
285
+ expect(processor).to receive(:stop)
286
+ expect(processor).to receive(:update_status)
287
+ expect(processor).to receive(:status).exactly(3).times.and_return('stopped')
288
288
 
289
- fiber.should_receive(:resume)
290
- Fiber.should_receive(:new).and_yield.and_return(fiber)
289
+ expect(fiber).to receive(:resume)
290
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
291
291
 
292
292
  new_exec = double('new_executive')
293
- new_exec.should_receive(:start)
293
+ expect(new_exec).to receive(:start)
294
294
 
295
- config.should_receive(:for_redis).and_return({})
295
+ expect(config).to receive(:for_redis).and_return({})
296
296
  fc = Flapjack::Coordinator.new(config)
297
297
 
298
- Flapjack::Pikelet.should_receive(:create).
298
+ expect(Flapjack::Pikelet).to receive(:create).
299
299
  with('processor', :config => new_cfg['processor'], :redis_config => {},
300
300
  :boot_time => time, :coordinator => fc).
301
301
  and_return(new_exec)
@@ -303,7 +303,7 @@ describe Flapjack::Coordinator do
303
303
  fc.instance_variable_set('@boot_time', time)
304
304
  fc.instance_variable_set('@pikelets', [processor])
305
305
  fc.reload
306
- fc.instance_variable_get('@pikelets').should == [new_exec]
306
+ expect(fc.instance_variable_get('@pikelets')).to eq([new_exec])
307
307
  end
308
308
 
309
309
  end
@@ -70,28 +70,36 @@ describe Flapjack::Data::Contact, :redis => true do
70
70
 
71
71
  it "returns a list of all contacts" do
72
72
  contacts = Flapjack::Data::Contact.all(:redis => @redis)
73
- contacts.should_not be_nil
74
- contacts.should be_an(Array)
75
- contacts.should have(2).contacts
76
- contacts[0].name.should == 'Jane Janeley'
77
- contacts[1].name.should == 'John Johnson'
73
+ expect(contacts).not_to be_nil
74
+ expect(contacts).to be_an(Array)
75
+ expect(contacts.size).to eq(2)
76
+ expect(contacts[0].name).to eq('Jane Janeley')
77
+ expect(contacts[1].name).to eq('John Johnson')
78
78
  end
79
79
 
80
80
  it "finds a contact by id" do
81
81
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
82
- contact.should_not be_nil
83
- contact.name.should == "John Johnson"
82
+ expect(contact).not_to be_nil
83
+ expect(contact.name).to eq("John Johnson")
84
+ end
85
+
86
+ it "finds contacts by ids" do
87
+ contacts = Flapjack::Data::Contact.find_by_ids(['c362','c363_a-f@42%*'], :redis => @redis)
88
+ expect(contacts).not_to be_nil
89
+ expect(contacts.length).to eq(2)
90
+ contact = contacts.first
91
+ expect(contact.name).to eq("John Johnson")
84
92
  end
85
93
 
86
94
  it "adds a contact with the same id as an existing one, clears notification rules" do
87
95
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
88
- contact.should_not be_nil
96
+ expect(contact).not_to be_nil
89
97
 
90
98
  contact.add_notification_rule(notification_rule_data)
91
99
 
92
100
  nr = contact.notification_rules
93
- nr.should_not be_nil
94
- nr.should have(2).notification_rules
101
+ expect(nr).not_to be_nil
102
+ expect(nr.size).to eq(2)
95
103
 
96
104
  Flapjack::Data::Contact.add({'id' => 'c363_a-f@42%*',
97
105
  'first_name' => 'Smithy',
@@ -100,44 +108,44 @@ describe Flapjack::Data::Contact, :redis => true do
100
108
  :redis => @redis)
101
109
 
102
110
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
103
- contact.should_not be_nil
104
- contact.name.should == 'Smithy Smith'
111
+ expect(contact).not_to be_nil
112
+ expect(contact.name).to eq('Smithy Smith')
105
113
  rules = contact.notification_rules
106
- rules.should have(1).notification_rule
107
- nr.map(&:id).should_not include(rules.first.id)
114
+ expect(rules.size).to eq(1)
115
+ expect(nr.map(&:id)).not_to include(rules.first.id)
108
116
  end
109
117
 
110
118
  it "updates a contact and clears their media settings" do
111
119
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
112
120
 
113
121
  contact.update('media' => {})
114
- contact.media.should be_empty
122
+ expect(contact.media).to be_empty
115
123
  end
116
124
 
117
125
  it "updates a contact, does not clear notification rules" do
118
126
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
119
- contact.should_not be_nil
127
+ expect(contact).not_to be_nil
120
128
 
121
129
  contact.add_notification_rule(notification_rule_data)
122
130
 
123
131
  nr1 = contact.notification_rules
124
- nr1.should_not be_nil
125
- nr1.should have(2).notification_rules
132
+ expect(nr1).not_to be_nil
133
+ expect(nr1.size).to eq(2)
126
134
 
127
135
  contact.update('first_name' => 'John',
128
136
  'last_name' => 'Smith',
129
137
  'email' => 'johns@example.com')
130
- contact.name.should == 'John Smith'
138
+ expect(contact.name).to eq('John Smith')
131
139
 
132
140
  nr2 = contact.notification_rules
133
- nr2.should_not be_nil
134
- nr2.should have(2).notification_rules
135
- nr1.map(&:id).should == nr2.map(&:id)
141
+ expect(nr2).not_to be_nil
142
+ expect(nr2.size).to eq(2)
143
+ expect(nr1.map(&:id)).to eq(nr2.map(&:id))
136
144
  end
137
145
 
138
146
  it "adds a notification rule for a contact" do
139
147
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
140
- contact.should_not be_nil
148
+ expect(contact).not_to be_nil
141
149
 
142
150
  expect {
143
151
  contact.add_notification_rule(notification_rule_data)
@@ -146,7 +154,7 @@ describe Flapjack::Data::Contact, :redis => true do
146
154
 
147
155
  it "removes a notification rule from a contact" do
148
156
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
149
- contact.should_not be_nil
157
+ expect(contact).not_to be_nil
150
158
 
151
159
  rule = contact.add_notification_rule(notification_rule_data)
152
160
 
@@ -161,29 +169,29 @@ describe Flapjack::Data::Contact, :redis => true do
161
169
  @redis.smembers("contact_notification_rules:c363_a-f@42%*").each do |rule_id|
162
170
  @redis.srem("contact_notification_rules:c363_a-f@42%*", rule_id)
163
171
  end
164
- @redis.smembers("contact_notification_rules:c363_a-f@42%*").should be_empty
172
+ expect(@redis.smembers("contact_notification_rules:c363_a-f@42%*")).to be_empty
165
173
 
166
174
  rules = contact.notification_rules
167
- rules.should have(1).rule
175
+ expect(rules.size).to eq(1)
168
176
  rule = rules.first
169
177
  [:entities, :tags, :time_restrictions,
170
178
  :warning_media, :critical_media,
171
179
  :warning_blackhole, :critical_blackhole].each do |k|
172
- rule.send(k).should == general_notification_rule_data[k]
180
+ expect(rule.send(k)).to eq(general_notification_rule_data[k])
173
181
  end
174
182
  end
175
183
 
176
184
  it "creates a general notification rule for a pre-existing contact if the existing general one was changed" do
177
185
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
178
186
  rules = contact.notification_rules
179
- rules.should have(1).notification_rule
187
+ expect(rules.size).to eq(1)
180
188
  rule = rules.first
181
189
 
182
190
  rule.update(notification_rule_data)
183
191
 
184
192
  rules = contact.notification_rules
185
- rules.should have(2).notification_rules
186
- rules.select {|r| r.is_specific? }.should have(1).rule
193
+ expect(rules.size).to eq(2)
194
+ expect(rules.select {|r| r.is_specific? }.size).to eq(1)
187
195
  end
188
196
 
189
197
  it "deletes a contact by id, including linked entities, checks, tags and notification rules" do
@@ -223,30 +231,30 @@ describe Flapjack::Data::Contact, :redis => true do
223
231
 
224
232
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
225
233
  eandcs = contact.entities(:checks => true)
226
- eandcs.should_not be_nil
227
- eandcs.should be_an(Array)
228
- eandcs.should have(1).entity_and_checks
234
+ expect(eandcs).not_to be_nil
235
+ expect(eandcs).to be_an(Array)
236
+ expect(eandcs.size).to eq(1)
229
237
 
230
238
  eandc = eandcs.first
231
- eandc.should be_a(Hash)
239
+ expect(eandc).to be_a(Hash)
232
240
 
233
241
  entity = eandc[:entity]
234
- entity.name.should == entity_name
242
+ expect(entity.name).to eq(entity_name)
235
243
  checks = eandc[:checks]
236
- checks.should be_a(Set)
237
- checks.should have(1).check
238
- checks.should include('PING')
244
+ expect(checks).to be_a(Set)
245
+ expect(checks.size).to eq(1)
246
+ expect(checks).to include('PING')
239
247
  end
240
248
 
241
249
  it "returns pagerduty credentials for a contact" do
242
250
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
243
251
  credentials = contact.pagerduty_credentials
244
- credentials.should_not be_nil
245
- credentials.should be_a(Hash)
246
- credentials.should == {'service_key' => '123456789012345678901234',
252
+ expect(credentials).not_to be_nil
253
+ expect(credentials).to be_a(Hash)
254
+ expect(credentials).to eq({'service_key' => '123456789012345678901234',
247
255
  'subdomain' => 'flpjck',
248
256
  'username' => 'flapjack',
249
- 'password' => 'very_secure'}
257
+ 'password' => 'very_secure'})
250
258
  end
251
259
 
252
260
  it "sets pagerduty credentials for a contact" do
@@ -256,78 +264,78 @@ describe Flapjack::Data::Contact, :redis => true do
256
264
  'username' => 'flapjack',
257
265
  'password' => 'tomato')
258
266
 
259
- @redis.hget('contact_media:c362', 'pagerduty').should == '567890123456789012345678'
260
- @redis.hgetall('contact_pagerduty:c362').should == {
267
+ expect(@redis.hget('contact_media:c362', 'pagerduty')).to eq('567890123456789012345678')
268
+ expect(@redis.hgetall('contact_pagerduty:c362')).to eq({
261
269
  'subdomain' => 'eggs',
262
270
  'username' => 'flapjack',
263
271
  'password' => 'tomato'
264
- }
272
+ })
265
273
  end
266
274
 
267
275
  it "sets the interval for a contact's media" do
268
276
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
269
277
  contact.set_interval_for_media('email', 42)
270
278
  email_interval_raw = @redis.hget("contact_media_intervals:#{contact.id}", 'email')
271
- email_interval_raw.should == '42'
279
+ expect(email_interval_raw).to eq('42')
272
280
  end
273
281
 
274
282
  it "returns the interval for a contact's media" do
275
283
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
276
284
  email_interval = contact.interval_for_media('email')
277
- email_interval.should == 60
285
+ expect(email_interval).to eq(60)
278
286
  end
279
287
 
280
288
  it "returns default 15 mins for interval for a contact's media that has no set interval" do
281
289
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
282
290
  email_interval = contact.interval_for_media('email')
283
- email_interval.should == 900
291
+ expect(email_interval).to eq(900)
284
292
  end
285
293
 
286
294
  it "removes the interval for a contact's media" do
287
295
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
288
296
  contact.set_interval_for_media('email', nil)
289
297
  email_interval_raw = @redis.hget("contact_media_intervals:#{contact.id}", 'email')
290
- email_interval_raw.should be_nil
298
+ expect(email_interval_raw).to be_nil
291
299
  end
292
300
 
293
301
  it "sets the rollup threshold for a contact's media" do
294
302
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
295
303
  email_rollup_threshold = contact.set_rollup_threshold_for_media('email', 3)
296
304
  email_rollup_threshold_raw = @redis.hget("contact_media_rollup_thresholds:#{contact.id}", 'email')
297
- email_rollup_threshold_raw.should == '3'
305
+ expect(email_rollup_threshold_raw).to eq('3')
298
306
  end
299
307
 
300
308
  it "returns the rollup threshold for a contact's media" do
301
309
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
302
310
  email_rollup_threshold = contact.rollup_threshold_for_media('email')
303
- email_rollup_threshold.should_not be_nil
304
- email_rollup_threshold.should be_a(Integer)
305
- email_rollup_threshold.should == 5
311
+ expect(email_rollup_threshold).not_to be_nil
312
+ expect(email_rollup_threshold).to be_a(Integer)
313
+ expect(email_rollup_threshold).to eq(5)
306
314
  end
307
315
 
308
316
  it "removes the rollup threshold for a contact's media" do
309
317
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
310
318
  email_rollup_threshold = contact.set_rollup_threshold_for_media('email', nil)
311
319
  email_rollup_threshold_raw = @redis.hget("contact_media_rollup_thresholds:#{contact.id}", 'email')
312
- email_rollup_threshold_raw.should be_nil
320
+ expect(email_rollup_threshold_raw).to be_nil
313
321
  end
314
322
 
315
323
  it "sets the address for a contact's media" do
316
324
  contact = Flapjack::Data::Contact.find_by_id('c362', :redis => @redis)
317
325
  contact.set_address_for_media('email', 'spongebob@example.com')
318
326
  email_address_raw = @redis.hget("contact_media:#{contact.id}", 'email')
319
- email_address_raw.should == 'spongebob@example.com'
327
+ expect(email_address_raw).to eq('spongebob@example.com')
320
328
  end
321
329
 
322
330
  it "removes a contact's media" do
323
331
  contact = Flapjack::Data::Contact.find_by_id('c363_a-f@42%*', :redis => @redis)
324
332
  contact.remove_media('email')
325
333
  email_address_raw = @redis.hget("contac_media:#{contact.id}", 'email')
326
- email_address_raw.should be_nil
334
+ expect(email_address_raw).to be_nil
327
335
  email_rollup_threshold_raw = @redis.hget("contact_media_rollup_thresholds:#{contact.id}", 'email')
328
- email_rollup_threshold_raw.should be_nil
336
+ expect(email_rollup_threshold_raw).to be_nil
329
337
  email_interval_raw = @redis.hget("contact_media_intervals:#{contact.id}", 'email')
330
- email_interval_raw.should be_nil
338
+ expect(email_interval_raw).to be_nil
331
339
  end
332
340
 
333
341
  end