flapjack 0.7.35 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -26,43 +26,43 @@ describe Flapjack::Data::EntityCheck, :redis => true do
26
26
 
27
27
  it "is created for an event id" do
28
28
  ec = Flapjack::Data::EntityCheck.for_event_id("#{name}:ping", :redis => @redis)
29
- ec.should_not be_nil
30
- ec.entity.should_not be_nil
31
- ec.entity.name.should_not be_nil
32
- ec.entity.name.should == name
33
- ec.check.should_not be_nil
34
- ec.check.should == 'ping'
29
+ expect(ec).not_to be_nil
30
+ expect(ec.entity).not_to be_nil
31
+ expect(ec.entity.name).not_to be_nil
32
+ expect(ec.entity.name).to eq(name)
33
+ expect(ec.check).not_to be_nil
34
+ expect(ec.check).to eq('ping')
35
35
  end
36
36
 
37
37
  it "is created for an entity name" do
38
38
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, 'ping', :redis => @redis)
39
- ec.should_not be_nil
40
- ec.entity.should_not be_nil
41
- ec.entity.name.should_not be_nil
42
- ec.entity.name.should == name
43
- ec.check.should_not be_nil
44
- ec.check.should == 'ping'
39
+ expect(ec).not_to be_nil
40
+ expect(ec.entity).not_to be_nil
41
+ expect(ec.entity.name).not_to be_nil
42
+ expect(ec.entity.name).to eq(name)
43
+ expect(ec.check).not_to be_nil
44
+ expect(ec.check).to eq('ping')
45
45
  end
46
46
 
47
47
  it "is created for an entity id" do
48
48
  ec = Flapjack::Data::EntityCheck.for_entity_id(5000, 'ping', :redis => @redis)
49
- ec.should_not be_nil
50
- ec.entity.should_not be_nil
51
- ec.entity.name.should_not be_nil
52
- ec.entity.name.should == name
53
- ec.check.should_not be_nil
54
- ec.check.should == 'ping'
49
+ expect(ec).not_to be_nil
50
+ expect(ec.entity).not_to be_nil
51
+ expect(ec.entity.name).not_to be_nil
52
+ expect(ec.entity.name).to eq(name)
53
+ expect(ec.check).not_to be_nil
54
+ expect(ec.check).to eq('ping')
55
55
  end
56
56
 
57
57
  it "is created for an entity object" do
58
58
  e = Flapjack::Data::Entity.find_by_name(name, :redis => @redis)
59
59
  ec = Flapjack::Data::EntityCheck.for_entity(e, 'ping', :redis => @redis)
60
- ec.should_not be_nil
61
- ec.entity.should_not be_nil
62
- ec.entity.name.should_not be_nil
63
- ec.entity.name.should == name
64
- ec.check.should_not be_nil
65
- ec.check.should == 'ping'
60
+ expect(ec).not_to be_nil
61
+ expect(ec.entity).not_to be_nil
62
+ expect(ec.entity.name).not_to be_nil
63
+ expect(ec.entity.name).to eq(name)
64
+ expect(ec.check).not_to be_nil
65
+ expect(ec.check).to eq('ping')
66
66
  end
67
67
 
68
68
  it "is not created for a missing entity" do
@@ -83,36 +83,36 @@ describe Flapjack::Data::EntityCheck, :redis => true do
83
83
  @redis.set("#{name}:#{check}:unscheduled_maintenance", Time.now.to_i.to_s)
84
84
 
85
85
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
86
- ec.should be_in_unscheduled_maintenance
86
+ expect(ec).to be_in_unscheduled_maintenance
87
87
  end
88
88
 
89
89
  it "returns that it is not in unscheduled maintenance" do
90
90
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
91
- ec.should_not be_in_unscheduled_maintenance
91
+ expect(ec).not_to be_in_unscheduled_maintenance
92
92
  end
93
93
 
94
94
  it "returns that it is in scheduled maintenance" do
95
95
  @redis.set("#{name}:#{check}:scheduled_maintenance", Time.now.to_i.to_s)
96
96
 
97
97
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
98
- ec.should be_in_scheduled_maintenance
98
+ expect(ec).to be_in_scheduled_maintenance
99
99
  end
100
100
 
101
101
  it "returns that it is not in scheduled maintenance" do
102
102
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
103
- ec.should_not be_in_scheduled_maintenance
103
+ expect(ec).not_to be_in_scheduled_maintenance
104
104
  end
105
105
 
106
106
  it "returns its current maintenance period" do
107
107
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
108
- ec.current_maintenance(:scheduled => true).should be_nil
108
+ expect(ec.current_maintenance(:scheduled => true)).to be_nil
109
109
 
110
110
  t = Time.now.to_i
111
111
 
112
112
  ec.create_unscheduled_maintenance(t, half_an_hour, :summary => 'oops')
113
- ec.current_maintenance.should == {:start_time => t,
113
+ expect(ec.current_maintenance).to eq({:start_time => t,
114
114
  :duration => half_an_hour,
115
- :summary => 'oops'}
115
+ :summary => 'oops'})
116
116
  end
117
117
 
118
118
  it "creates an unscheduled maintenance period" do
@@ -120,27 +120,27 @@ describe Flapjack::Data::EntityCheck, :redis => true do
120
120
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
121
121
  ec.create_unscheduled_maintenance(t, half_an_hour, :summary => 'oops')
122
122
 
123
- ec.should be_in_unscheduled_maintenance
123
+ expect(ec).to be_in_unscheduled_maintenance
124
124
 
125
125
  umps = ec.maintenances(nil, nil, :scheduled => false)
126
- umps.should_not be_nil
127
- umps.should be_an(Array)
128
- umps.should have(1).unscheduled_maintenance_period
129
- umps[0].should be_a(Hash)
126
+ expect(umps).not_to be_nil
127
+ expect(umps).to be_an(Array)
128
+ expect(umps.size).to eq(1)
129
+ expect(umps[0]).to be_a(Hash)
130
130
 
131
131
  start_time = umps[0][:start_time]
132
- start_time.should_not be_nil
133
- start_time.should be_an(Integer)
134
- start_time.should == t
132
+ expect(start_time).not_to be_nil
133
+ expect(start_time).to be_an(Integer)
134
+ expect(start_time).to eq(t)
135
135
 
136
136
  duration = umps[0][:duration]
137
- duration.should_not be_nil
138
- duration.should be_a(Float)
139
- duration.should == half_an_hour
137
+ expect(duration).not_to be_nil
138
+ expect(duration).to be_a(Float)
139
+ expect(duration).to eq(half_an_hour)
140
140
 
141
141
  summary = @redis.get("#{name}:#{check}:#{t}:unscheduled_maintenance:summary")
142
- summary.should_not be_nil
143
- summary.should == 'oops'
142
+ expect(summary).not_to be_nil
143
+ expect(summary).to eq('oops')
144
144
  end
145
145
 
146
146
  it "creates an unscheduled maintenance period and ends the current one early", :time => true do
@@ -151,33 +151,33 @@ describe Flapjack::Data::EntityCheck, :redis => true do
151
151
  Delorean.time_travel_to( Time.at(later_t) )
152
152
  ec.create_unscheduled_maintenance(later_t, half_an_hour, :summary => 'spoo')
153
153
 
154
- ec.should be_in_unscheduled_maintenance
154
+ expect(ec).to be_in_unscheduled_maintenance
155
155
 
156
156
  umps = ec.maintenances(nil, nil, :scheduled => false)
157
- umps.should_not be_nil
158
- umps.should be_an(Array)
159
- umps.should have(2).unscheduled_maintenance_periods
160
- umps[0].should be_a(Hash)
157
+ expect(umps).not_to be_nil
158
+ expect(umps).to be_an(Array)
159
+ expect(umps.size).to eq(2)
160
+ expect(umps[0]).to be_a(Hash)
161
161
 
162
162
  start_time = umps[0][:start_time]
163
- start_time.should_not be_nil
164
- start_time.should be_an(Integer)
165
- start_time.should == t
163
+ expect(start_time).not_to be_nil
164
+ expect(start_time).to be_an(Integer)
165
+ expect(start_time).to eq(t)
166
166
 
167
167
  duration = umps[0][:duration]
168
- duration.should_not be_nil
169
- duration.should be_a(Float)
170
- duration.should == (15 * 60)
168
+ expect(duration).not_to be_nil
169
+ expect(duration).to be_a(Float)
170
+ expect(duration).to eq(15 * 60)
171
171
 
172
172
  start_time_curr = umps[1][:start_time]
173
- start_time_curr.should_not be_nil
174
- start_time_curr.should be_an(Integer)
175
- start_time_curr.should == later_t
173
+ expect(start_time_curr).not_to be_nil
174
+ expect(start_time_curr).to be_an(Integer)
175
+ expect(start_time_curr).to eq(later_t)
176
176
 
177
177
  duration_curr = umps[1][:duration]
178
- duration_curr.should_not be_nil
179
- duration_curr.should be_a(Float)
180
- duration_curr.should == half_an_hour
178
+ expect(duration_curr).not_to be_nil
179
+ expect(duration_curr).to be_a(Float)
180
+ expect(duration_curr).to eq(half_an_hour)
181
181
  end
182
182
 
183
183
  it "ends an unscheduled maintenance period" do
@@ -186,28 +186,28 @@ describe Flapjack::Data::EntityCheck, :redis => true do
186
186
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
187
187
 
188
188
  ec.create_unscheduled_maintenance(t, half_an_hour, :summary => 'oops')
189
- ec.should be_in_unscheduled_maintenance
189
+ expect(ec).to be_in_unscheduled_maintenance
190
190
 
191
191
  Delorean.time_travel_to( Time.at(later_t) )
192
- ec.should be_in_unscheduled_maintenance
192
+ expect(ec).to be_in_unscheduled_maintenance
193
193
  ec.end_unscheduled_maintenance(later_t)
194
- ec.should_not be_in_unscheduled_maintenance
194
+ expect(ec).not_to be_in_unscheduled_maintenance
195
195
 
196
196
  umps = ec.maintenances(nil, nil, :scheduled => false)
197
- umps.should_not be_nil
198
- umps.should be_an(Array)
199
- umps.should have(1).unscheduled_maintenance_period
200
- umps[0].should be_a(Hash)
197
+ expect(umps).not_to be_nil
198
+ expect(umps).to be_an(Array)
199
+ expect(umps.size).to eq(1)
200
+ expect(umps[0]).to be_a(Hash)
201
201
 
202
202
  start_time = umps[0][:start_time]
203
- start_time.should_not be_nil
204
- start_time.should be_an(Integer)
205
- start_time.should == t
203
+ expect(start_time).not_to be_nil
204
+ expect(start_time).to be_an(Integer)
205
+ expect(start_time).to eq(t)
206
206
 
207
207
  duration = umps[0][:duration]
208
- duration.should_not be_nil
209
- duration.should be_a(Float)
210
- duration.should == (15 * 60)
208
+ expect(duration).not_to be_nil
209
+ expect(duration).to be_a(Float)
210
+ expect(duration).to eq(15 * 60)
211
211
  end
212
212
 
213
213
  it "creates a scheduled maintenance period for a future time" do
@@ -217,20 +217,20 @@ describe Flapjack::Data::EntityCheck, :redis => true do
217
217
  half_an_hour, :summary => "30 minutes")
218
218
 
219
219
  smps = ec.maintenances(nil, nil, :scheduled => true)
220
- smps.should_not be_nil
221
- smps.should be_an(Array)
222
- smps.should have(1).scheduled_maintenance_period
223
- smps[0].should be_a(Hash)
220
+ expect(smps).not_to be_nil
221
+ expect(smps).to be_an(Array)
222
+ expect(smps.size).to eq(1)
223
+ expect(smps[0]).to be_a(Hash)
224
224
 
225
225
  start_time = smps[0][:start_time]
226
- start_time.should_not be_nil
227
- start_time.should be_an(Integer)
228
- start_time.should == (t + (60 * 60))
226
+ expect(start_time).not_to be_nil
227
+ expect(start_time).to be_an(Integer)
228
+ expect(start_time).to eq(t + (60 * 60))
229
229
 
230
230
  duration = smps[0][:duration]
231
- duration.should_not be_nil
232
- duration.should be_a(Float)
233
- duration.should == half_an_hour
231
+ expect(duration).not_to be_nil
232
+ expect(duration).to be_a(Float)
233
+ expect(duration).to eq(half_an_hour)
234
234
  end
235
235
 
236
236
  # TODO this should probably enforce that it starts in the future
@@ -241,20 +241,20 @@ describe Flapjack::Data::EntityCheck, :redis => true do
241
241
  2 * (60 * 60), :summary => "2 hours")
242
242
 
243
243
  smps = ec.maintenances(nil, nil, :scheduled => true)
244
- smps.should_not be_nil
245
- smps.should be_an(Array)
246
- smps.should have(1).scheduled_maintenance_period
247
- smps[0].should be_a(Hash)
244
+ expect(smps).not_to be_nil
245
+ expect(smps).to be_an(Array)
246
+ expect(smps.size).to eq(1)
247
+ expect(smps[0]).to be_a(Hash)
248
248
 
249
249
  start_time = smps[0][:start_time]
250
- start_time.should_not be_nil
251
- start_time.should be_an(Integer)
252
- start_time.should == (t - (60 * 60))
250
+ expect(start_time).not_to be_nil
251
+ expect(start_time).to be_an(Integer)
252
+ expect(start_time).to eq(t - (60 * 60))
253
253
 
254
254
  duration = smps[0][:duration]
255
- duration.should_not be_nil
256
- duration.should be_a(Float)
257
- duration.should == 2 * (60 * 60)
255
+ expect(duration).not_to be_nil
256
+ expect(duration).to be_a(Float)
257
+ expect(duration).to eq(2 * (60 * 60))
258
258
  end
259
259
 
260
260
  it "removes a scheduled maintenance period for a future time" do
@@ -266,9 +266,9 @@ describe Flapjack::Data::EntityCheck, :redis => true do
266
266
  ec.end_scheduled_maintenance(t + (60 * 60))
267
267
 
268
268
  smps = ec.maintenances(nil, nil, :scheduled => true)
269
- smps.should_not be_nil
270
- smps.should be_an(Array)
271
- smps.should be_empty
269
+ expect(smps).not_to be_nil
270
+ expect(smps).to be_an(Array)
271
+ expect(smps).to be_empty
272
272
  end
273
273
 
274
274
  # maint period starts an hour from now, goes for two hours -- at 30 minutes into
@@ -284,11 +284,11 @@ describe Flapjack::Data::EntityCheck, :redis => true do
284
284
  ec.end_scheduled_maintenance(t + (60 * 60))
285
285
 
286
286
  smps = ec.maintenances(nil, nil, :scheduled => true)
287
- smps.should_not be_nil
288
- smps.should be_an(Array)
289
- smps.should_not be_empty
290
- smps.should have(1).item
291
- smps.first[:duration].should == (30 * 60)
287
+ expect(smps).not_to be_nil
288
+ expect(smps).to be_an(Array)
289
+ expect(smps).not_to be_empty
290
+ expect(smps.size).to eq(1)
291
+ expect(smps.first[:duration]).to eq(30 * 60)
292
292
  end
293
293
 
294
294
  it "does not alter or remove a scheduled maintenance period covering a past time", :time => true do
@@ -302,11 +302,11 @@ describe Flapjack::Data::EntityCheck, :redis => true do
302
302
  ec.end_scheduled_maintenance(t + (60 * 60))
303
303
 
304
304
  smps = ec.maintenances(nil, nil, :scheduled => true)
305
- smps.should_not be_nil
306
- smps.should be_an(Array)
307
- smps.should_not be_empty
308
- smps.should have(1).item
309
- smps.first[:duration].should == 2 * (60 * 60)
305
+ expect(smps).not_to be_nil
306
+ expect(smps).to be_an(Array)
307
+ expect(smps).not_to be_empty
308
+ expect(smps.size).to eq(1)
309
+ expect(smps.first[:duration]).to eq(2 * (60 * 60))
310
310
  end
311
311
 
312
312
  it "returns a list of scheduled maintenance periods" do
@@ -321,17 +321,17 @@ describe Flapjack::Data::EntityCheck, :redis => true do
321
321
  :summary => "second")
322
322
 
323
323
  smp = ec.maintenances(nil, nil, :scheduled => true)
324
- smp.should_not be_nil
325
- smp.should be_an(Array)
326
- smp.should have(2).scheduled_maintenance_periods
327
- smp[0].should == {:start_time => five_hours_ago,
324
+ expect(smp).not_to be_nil
325
+ expect(smp).to be_an(Array)
326
+ expect(smp.size).to eq(2)
327
+ expect(smp[0]).to eq({:start_time => five_hours_ago,
328
328
  :end_time => five_hours_ago + half_an_hour,
329
329
  :duration => half_an_hour,
330
- :summary => "first"}
331
- smp[1].should == {:start_time => three_hours_ago,
330
+ :summary => "first"})
331
+ expect(smp[1]).to eq({:start_time => three_hours_ago,
332
332
  :end_time => three_hours_ago + half_an_hour,
333
333
  :duration => half_an_hour,
334
- :summary => "second"}
334
+ :summary => "second"})
335
335
  end
336
336
 
337
337
  it "returns a list of unscheduled maintenance periods" do
@@ -346,17 +346,17 @@ describe Flapjack::Data::EntityCheck, :redis => true do
346
346
  half_an_hour, :summary => "second")
347
347
 
348
348
  ump = ec.maintenances(nil, nil, :scheduled => false)
349
- ump.should_not be_nil
350
- ump.should be_an(Array)
351
- ump.should have(2).unscheduled_maintenance_periods
352
- ump[0].should == {:start_time => five_hours_ago,
349
+ expect(ump).not_to be_nil
350
+ expect(ump).to be_an(Array)
351
+ expect(ump.size).to eq(2)
352
+ expect(ump[0]).to eq({:start_time => five_hours_ago,
353
353
  :end_time => five_hours_ago + half_an_hour,
354
354
  :duration => half_an_hour,
355
- :summary => "first"}
356
- ump[1].should == {:start_time => three_hours_ago,
355
+ :summary => "first"})
356
+ expect(ump[1]).to eq({:start_time => three_hours_ago,
357
357
  :end_time => three_hours_ago + half_an_hour,
358
358
  :duration => half_an_hour,
359
- :summary => "second"}
359
+ :summary => "second"})
360
360
  end
361
361
 
362
362
  end
@@ -366,8 +366,8 @@ describe Flapjack::Data::EntityCheck, :redis => true do
366
366
 
367
367
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
368
368
  state = ec.state
369
- state.should_not be_nil
370
- state.should == 'ok'
369
+ expect(state).not_to be_nil
370
+ expect(state).to eq('ok')
371
371
  end
372
372
 
373
373
  it "updates state" do
@@ -379,11 +379,11 @@ describe Flapjack::Data::EntityCheck, :redis => true do
379
379
  ec.update_state('critical')
380
380
 
381
381
  state = @redis.hget("check:#{name}:#{check}", 'state')
382
- state.should_not be_nil
383
- state.should == 'critical'
382
+ expect(state).not_to be_nil
383
+ expect(state).to eq('critical')
384
384
 
385
385
  new_timestamp = @redis.hget("check:#{name}:#{check}", 'last_update')
386
- new_timestamp.should_not == old_timestamp
386
+ expect(new_timestamp).not_to eq(old_timestamp)
387
387
  end
388
388
 
389
389
  it "updates enabled checks" do
@@ -392,11 +392,11 @@ describe Flapjack::Data::EntityCheck, :redis => true do
392
392
  ec.last_update = ts
393
393
 
394
394
  saved_check_ts = @redis.zscore("current_checks:#{name}", check)
395
- saved_check_ts.should_not be_nil
396
- saved_check_ts.should == ts
395
+ expect(saved_check_ts).not_to be_nil
396
+ expect(saved_check_ts).to eq(ts)
397
397
  saved_entity_ts = @redis.zscore("current_entities", name)
398
- saved_entity_ts.should_not be_nil
399
- saved_entity_ts.should == ts
398
+ expect(saved_entity_ts).not_to be_nil
399
+ expect(saved_entity_ts).to eq(ts)
400
400
  end
401
401
 
402
402
  it "exposes that it is enabled" do
@@ -405,14 +405,14 @@ describe Flapjack::Data::EntityCheck, :redis => true do
405
405
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
406
406
 
407
407
  e = ec.enabled?
408
- e.should be_true
408
+ expect(e).to be true
409
409
  end
410
410
 
411
411
  it "exposes that it is disabled" do
412
412
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
413
413
 
414
414
  e = ec.enabled?
415
- e.should be_false
415
+ expect(e).to be false
416
416
  end
417
417
 
418
418
  it "disables checks" do
@@ -423,8 +423,8 @@ describe Flapjack::Data::EntityCheck, :redis => true do
423
423
 
424
424
  saved_check_ts = @redis.zscore("current_checks:#{name}", check)
425
425
  saved_entity_ts = @redis.zscore("current_entities", name)
426
- saved_check_ts.should be_nil
427
- saved_entity_ts.should be_nil
426
+ expect(saved_check_ts).to be_nil
427
+ expect(saved_entity_ts).to be_nil
428
428
  end
429
429
 
430
430
  it "does not update state with invalid value" do
@@ -434,8 +434,8 @@ describe Flapjack::Data::EntityCheck, :redis => true do
434
434
  ec.update_state('silly')
435
435
 
436
436
  state = @redis.hget("check:#{name}:#{check}", 'state')
437
- state.should_not be_nil
438
- state.should == 'ok'
437
+ expect(state).not_to be_nil
438
+ expect(state).to eq('ok')
439
439
  end
440
440
 
441
441
  it "does not update state with a repeated state value" do
@@ -448,15 +448,15 @@ describe Flapjack::Data::EntityCheck, :redis => true do
448
448
  new_changed_at = @redis.hget("check:#{name}:#{check}", 'last_change')
449
449
  new_summary = @redis.hget("check:#{name}:#{check}", 'summary')
450
450
 
451
- changed_at.should_not be_nil
452
- new_changed_at.should_not be_nil
453
- new_changed_at.should == changed_at
451
+ expect(changed_at).not_to be_nil
452
+ expect(new_changed_at).not_to be_nil
453
+ expect(new_changed_at).to eq(changed_at)
454
454
 
455
- summary.should_not be_nil
456
- new_summary.should_not be_nil
457
- new_summary.should_not == summary
458
- summary.should == 'small problem'
459
- new_summary.should == 'big problem'
455
+ expect(summary).not_to be_nil
456
+ expect(new_summary).not_to be_nil
457
+ expect(new_summary).not_to eq(summary)
458
+ expect(summary).to eq('small problem')
459
+ expect(new_summary).to eq('big problem')
460
460
  end
461
461
 
462
462
  def time_before(t, min, sec = 0)
@@ -474,13 +474,13 @@ describe Flapjack::Data::EntityCheck, :redis => true do
474
474
  ec.update_state('ok', :timestamp => time_before(t, 1), :summary => 'e')
475
475
 
476
476
  states = ec.historical_states(time_before(t, 4), t)
477
- states.should_not be_nil
478
- states.should be_an(Array)
479
- states.should have(4).data_hashes
480
- states[0][:summary].should == 'b'
481
- states[1][:summary].should == 'c'
482
- states[2][:summary].should == 'd'
483
- states[3][:summary].should == 'e'
477
+ expect(states).not_to be_nil
478
+ expect(states).to be_an(Array)
479
+ expect(states.size).to eq(4)
480
+ expect(states[0][:summary]).to eq('b')
481
+ expect(states[1][:summary]).to eq('c')
482
+ expect(states[2][:summary]).to eq('d')
483
+ expect(states[3][:summary]).to eq('e')
484
484
  end
485
485
 
486
486
  it "returns a list of historical unscheduled maintenances for a time range" do
@@ -494,13 +494,13 @@ describe Flapjack::Data::EntityCheck, :redis => true do
494
494
  ec.update_state('ok', :timestamp => time_before(t, 1), :summary => 'e')
495
495
 
496
496
  states = ec.historical_states(time_before(t, 4), t)
497
- states.should_not be_nil
498
- states.should be_an(Array)
499
- states.should have(4).data_hashes
500
- states[0][:summary].should == 'b'
501
- states[1][:summary].should == 'c'
502
- states[2][:summary].should == 'd'
503
- states[3][:summary].should == 'e'
497
+ expect(states).not_to be_nil
498
+ expect(states).to be_an(Array)
499
+ expect(states.size).to eq(4)
500
+ expect(states[0][:summary]).to eq('b')
501
+ expect(states[1][:summary]).to eq('c')
502
+ expect(states[2][:summary]).to eq('d')
503
+ expect(states[3][:summary]).to eq('e')
504
504
  end
505
505
 
506
506
  it "returns a list of historical scheduled maintenances for a time range" do
@@ -517,34 +517,34 @@ describe Flapjack::Data::EntityCheck, :redis => true do
517
517
 
518
518
  sched_maint_periods = ec.maintenances(time_before(t, 150), t,
519
519
  :scheduled => true)
520
- sched_maint_periods.should_not be_nil
521
- sched_maint_periods.should be_an(Array)
522
- sched_maint_periods.should have(2).data_hashes
523
- sched_maint_periods[0][:summary].should == 'b'
524
- sched_maint_periods[1][:summary].should == 'c'
520
+ expect(sched_maint_periods).not_to be_nil
521
+ expect(sched_maint_periods).to be_an(Array)
522
+ expect(sched_maint_periods.size).to eq(2)
523
+ expect(sched_maint_periods[0][:summary]).to eq('b')
524
+ expect(sched_maint_periods[1][:summary]).to eq('c')
525
525
  end
526
526
 
527
527
  it "returns that it has failed" do
528
528
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
529
529
 
530
530
  @redis.hset("check:#{name}:#{check}", 'state', 'warning')
531
- ec.should be_failed
531
+ expect(ec).to be_failed
532
532
 
533
533
  @redis.hset("check:#{name}:#{check}", 'state', 'critical')
534
- ec.should be_failed
534
+ expect(ec).to be_failed
535
535
 
536
536
  @redis.hset("check:#{name}:#{check}", 'state', 'unknown')
537
- ec.should be_failed
537
+ expect(ec).to be_failed
538
538
  end
539
539
 
540
540
  it "returns that it has not failed" do
541
541
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
542
542
 
543
543
  @redis.hset("check:#{name}:#{check}", 'state', 'ok')
544
- ec.should_not be_failed
544
+ expect(ec).not_to be_failed
545
545
 
546
546
  @redis.hset("check:#{name}:#{check}", 'state', 'acknowledgement')
547
- ec.should_not be_failed
547
+ expect(ec).not_to be_failed
548
548
  end
549
549
 
550
550
  it "returns a status summary" do
@@ -557,7 +557,7 @@ describe Flapjack::Data::EntityCheck, :redis => true do
557
557
  ec.update_state('critical', :timestamp => time_before(t, 2), :summary => 'd')
558
558
 
559
559
  summary = ec.summary
560
- summary.should == 'd'
560
+ expect(summary).to eq('d')
561
561
  end
562
562
 
563
563
  it "returns timestamps for its last notifications" do
@@ -567,26 +567,26 @@ describe Flapjack::Data::EntityCheck, :redis => true do
567
567
  @redis.set("#{name}:#{check}:last_recovery_notification", t)
568
568
 
569
569
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
570
- ec.last_notification_for_state(:problem)[:timestamp].should == t - 30
571
- ec.last_notification_for_state(:acknowledgement)[:timestamp].should == t - 15
572
- ec.last_notification_for_state(:recovery)[:timestamp].should == t
570
+ expect(ec.last_notification_for_state(:problem)[:timestamp]).to eq(t - 30)
571
+ expect(ec.last_notification_for_state(:acknowledgement)[:timestamp]).to eq(t - 15)
572
+ expect(ec.last_notification_for_state(:recovery)[:timestamp]).to eq(t)
573
573
  end
574
574
 
575
575
  it "finds all related contacts" do
576
576
  ec = Flapjack::Data::EntityCheck.for_entity_name(name, check, :redis => @redis)
577
577
  contacts = ec.contacts
578
- contacts.should_not be_nil
579
- contacts.should be_an(Array)
580
- contacts.should have(1).contact
581
- contacts.first.name.should == 'John Johnson'
578
+ expect(contacts).not_to be_nil
579
+ expect(contacts).to be_an(Array)
580
+ expect(contacts.size).to eq(1)
581
+ expect(contacts.first.name).to eq('John Johnson')
582
582
  end
583
583
 
584
584
  it "generates ephemeral tags for itself" do
585
585
  ec = Flapjack::Data::EntityCheck.for_entity_name('foo-app-01.example.com', 'Disk / Utilisation', :redis => @redis)
586
586
  tags = ec.tags
587
- tags.should_not be_nil
588
- tags.should be_a(Flapjack::Data::TagSet)
589
- ['foo-app-01', 'example.com', 'disk', '/', 'utilisation'].to_set.subset?(tags).should be_true
587
+ expect(tags).not_to be_nil
588
+ expect(tags).to be_a(Flapjack::Data::TagSet)
589
+ expect(['foo-app-01', 'example.com', 'disk', '/', 'utilisation'].to_set.subset?(tags)).to be true
590
590
  end
591
591
 
592
592
  end