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
@@ -9,9 +9,9 @@ describe Flapjack::Data::Entity, :redis => true do
9
9
  it "creates an entity if allowed when it can't find it" do
10
10
  entity = Flapjack::Data::Entity.find_by_name(name, :redis => @redis, :create => true)
11
11
 
12
- entity.should_not be_nil
13
- entity.name.should == name
14
- @redis.get("entity_id:#{name}").should == ''
12
+ expect(entity).not_to be_nil
13
+ expect(entity.name).to eq(name)
14
+ expect(@redis.get("entity_id:#{name}")).to eq('')
15
15
  end
16
16
 
17
17
  it "adds a registered contact with an entity" do
@@ -27,12 +27,12 @@ describe Flapjack::Data::Entity, :redis => true do
27
27
  :redis => @redis)
28
28
 
29
29
  entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
30
- entity.should_not be_nil
30
+ expect(entity).not_to be_nil
31
31
  contacts = entity.contacts
32
- contacts.should_not be_nil
33
- contacts.should be_an(Array)
34
- contacts.should have(1).contact
35
- contacts.first.name.should == 'John Johnson'
32
+ expect(contacts).not_to be_nil
33
+ expect(contacts).to be_an(Array)
34
+ expect(contacts.size).to eq(1)
35
+ expect(contacts.first.name).to eq('John Johnson')
36
36
  end
37
37
 
38
38
  it "does not add a registered contact with an entity if the contact is unknown" do
@@ -42,11 +42,11 @@ describe Flapjack::Data::Entity, :redis => true do
42
42
  :redis => @redis)
43
43
 
44
44
  entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
45
- entity.should_not be_nil
45
+ expect(entity).not_to be_nil
46
46
  contacts = entity.contacts
47
- contacts.should_not be_nil
48
- contacts.should be_an(Array)
49
- contacts.should be_empty
47
+ expect(contacts).not_to be_nil
48
+ expect(contacts).to be_an(Array)
49
+ expect(contacts).to be_empty
50
50
  end
51
51
 
52
52
  it "finds an entity by id" do
@@ -55,8 +55,8 @@ describe Flapjack::Data::Entity, :redis => true do
55
55
  :redis => @redis)
56
56
 
57
57
  entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
58
- entity.should_not be_nil
59
- entity.name.should == name
58
+ expect(entity).not_to be_nil
59
+ expect(entity.name).to eq(name)
60
60
  end
61
61
 
62
62
  it "finds an entity by name" do
@@ -65,8 +65,8 @@ describe Flapjack::Data::Entity, :redis => true do
65
65
  :redis => @redis)
66
66
 
67
67
  entity = Flapjack::Data::Entity.find_by_name(name, :redis => @redis)
68
- entity.should_not be_nil
69
- entity.id.should == '5000'
68
+ expect(entity).not_to be_nil
69
+ expect(entity.id).to eq('5000')
70
70
  end
71
71
 
72
72
  it "returns a list of all entities" do
@@ -78,11 +78,11 @@ describe Flapjack::Data::Entity, :redis => true do
78
78
  :redis => @redis)
79
79
 
80
80
  entities = Flapjack::Data::Entity.all(:redis => @redis)
81
- entities.should_not be_nil
82
- entities.should be_an(Array)
83
- entities.should have(2).entities
84
- entities[0].id.should == '5000'
85
- entities[1].id.should == '5001'
81
+ expect(entities).not_to be_nil
82
+ expect(entities).to be_an(Array)
83
+ expect(entities.size).to eq(2)
84
+ expect(entities[0].id).to eq('5000')
85
+ expect(entities[1].id).to eq('5001')
86
86
  end
87
87
 
88
88
  it "returns a list of checks for an entity" do
@@ -95,11 +95,11 @@ describe Flapjack::Data::Entity, :redis => true do
95
95
 
96
96
  entity = Flapjack::Data::Entity.find_by_name(name, :redis => @redis)
97
97
  check_list = entity.check_list
98
- check_list.should_not be_nil
99
- check_list.should have(2).checks
98
+ expect(check_list).not_to be_nil
99
+ expect(check_list.size).to eq(2)
100
100
  sorted_list = check_list.sort
101
- sorted_list[0].should == 'ping'
102
- sorted_list[1].should == 'ssh'
101
+ expect(sorted_list[0]).to eq('ping')
102
+ expect(sorted_list[1]).to eq('ssh')
103
103
  end
104
104
 
105
105
  it "returns a count of checks for an entity" do
@@ -113,8 +113,8 @@ describe Flapjack::Data::Entity, :redis => true do
113
113
 
114
114
  entity = Flapjack::Data::Entity.find_by_id(5000, :redis => @redis)
115
115
  check_count = entity.check_count
116
- check_count.should_not be_nil
117
- check_count.should == 2
116
+ expect(check_count).not_to be_nil
117
+ expect(check_count).to eq(2)
118
118
  end
119
119
 
120
120
  it "finds entity names matching a pattern" do
@@ -129,10 +129,10 @@ describe Flapjack::Data::Entity, :redis => true do
129
129
  :redis => @redis)
130
130
 
131
131
  entities = Flapjack::Data::Entity.find_all_name_matching('abc', :redis => @redis)
132
- entities.should_not be_nil
133
- entities.should be_an(Array)
134
- entities.should have(1).entity
135
- entities.first.should == 'abc-123'
132
+ expect(entities).not_to be_nil
133
+ expect(entities).to be_an(Array)
134
+ expect(entities.size).to eq(1)
135
+ expect(entities.first).to eq('abc-123')
136
136
  end
137
137
 
138
138
  it "adds tags to entities" do
@@ -143,16 +143,16 @@ describe Flapjack::Data::Entity, :redis => true do
143
143
 
144
144
  entity.add_tags('source:foobar', 'foo')
145
145
 
146
- entity.should_not be_nil
147
- entity.should be_an(Flapjack::Data::Entity)
148
- entity.name.should == 'abc-123'
149
- entity.tags.should include("source:foobar")
150
- entity.tags.should include("foo")
146
+ expect(entity).not_to be_nil
147
+ expect(entity).to be_an(Flapjack::Data::Entity)
148
+ expect(entity.name).to eq('abc-123')
149
+ expect(entity.tags).to include("source:foobar")
150
+ expect(entity.tags).to include("foo")
151
151
 
152
152
  # and test the tags as read back from redis
153
153
  entity = Flapjack::Data::Entity.find_by_id('5000', :redis => @redis)
154
- entity.tags.should include("source:foobar")
155
- entity.tags.should include("foo")
154
+ expect(entity.tags).to include("source:foobar")
155
+ expect(entity.tags).to include("foo")
156
156
 
157
157
  end
158
158
 
@@ -164,14 +164,14 @@ describe Flapjack::Data::Entity, :redis => true do
164
164
 
165
165
  entity.add_tags('source:foobar', 'foo')
166
166
 
167
- entity.should_not be_nil
168
- entity.tags.should include("source:foobar")
169
- entity.tags.should include("foo")
167
+ expect(entity).not_to be_nil
168
+ expect(entity.tags).to include("source:foobar")
169
+ expect(entity.tags).to include("foo")
170
170
 
171
171
  entity.delete_tags('source:foobar')
172
172
 
173
- entity.tags.should_not include("source:foobar")
174
- entity.tags.should include("foo")
173
+ expect(entity.tags).not_to include("source:foobar")
174
+ expect(entity.tags).to include("foo")
175
175
 
176
176
  end
177
177
 
@@ -189,25 +189,25 @@ describe Flapjack::Data::Entity, :redis => true do
189
189
  entity0.add_tags('source:foobar', 'abc')
190
190
  entity1.add_tags('source:foobar', 'def')
191
191
 
192
- entity0.should_not be_nil
193
- entity0.should be_an(Flapjack::Data::Entity)
194
- entity0.tags.should include("source:foobar")
195
- entity0.tags.should include("abc")
196
- entity0.tags.should_not include("def")
197
- entity1.should_not be_nil
198
- entity1.should be_an(Flapjack::Data::Entity)
199
- entity1.tags.should include("source:foobar")
200
- entity1.tags.should include("def")
201
- entity1.tags.should_not include("abc")
192
+ expect(entity0).not_to be_nil
193
+ expect(entity0).to be_an(Flapjack::Data::Entity)
194
+ expect(entity0.tags).to include("source:foobar")
195
+ expect(entity0.tags).to include("abc")
196
+ expect(entity0.tags).not_to include("def")
197
+ expect(entity1).not_to be_nil
198
+ expect(entity1).to be_an(Flapjack::Data::Entity)
199
+ expect(entity1.tags).to include("source:foobar")
200
+ expect(entity1.tags).to include("def")
201
+ expect(entity1.tags).not_to include("abc")
202
202
 
203
203
  entities = Flapjack::Data::Entity.find_all_with_tags(['abc'], :redis => @redis)
204
- entities.should be_an(Array)
205
- entities.should have(1).entity
206
- entities.first.should == 'abc-123'
204
+ expect(entities).to be_an(Array)
205
+ expect(entities.size).to eq(1)
206
+ expect(entities.first).to eq('abc-123')
207
207
 
208
208
  entities = Flapjack::Data::Entity.find_all_with_tags(['donkey'], :redis => @redis)
209
- entities.should be_an(Array)
210
- entities.should have(0).entities
209
+ expect(entities).to be_an(Array)
210
+ expect(entities).to be_empty
211
211
  end
212
212
 
213
213
  it "finds entities with several tags" do
@@ -224,23 +224,23 @@ describe Flapjack::Data::Entity, :redis => true do
224
224
  entity0.add_tags('source:foobar', 'abc')
225
225
  entity1.add_tags('source:foobar', 'def')
226
226
 
227
- entity0.should_not be_nil
228
- entity0.should be_an(Flapjack::Data::Entity)
229
- entity0.tags.should include("source:foobar")
230
- entity0.tags.should include("abc")
231
- entity1.should_not be_nil
232
- entity1.should be_an(Flapjack::Data::Entity)
233
- entity1.tags.should include("source:foobar")
234
- entity1.tags.should include("def")
227
+ expect(entity0).not_to be_nil
228
+ expect(entity0).to be_an(Flapjack::Data::Entity)
229
+ expect(entity0.tags).to include("source:foobar")
230
+ expect(entity0.tags).to include("abc")
231
+ expect(entity1).not_to be_nil
232
+ expect(entity1).to be_an(Flapjack::Data::Entity)
233
+ expect(entity1.tags).to include("source:foobar")
234
+ expect(entity1.tags).to include("def")
235
235
 
236
236
  entities = Flapjack::Data::Entity.find_all_with_tags(['source:foobar'], :redis => @redis)
237
- entities.should be_an(Array)
238
- entities.should have(2).entity
237
+ expect(entities).to be_an(Array)
238
+ expect(entities.size).to eq(2)
239
239
 
240
240
  entities = Flapjack::Data::Entity.find_all_with_tags(['source:foobar', 'def'], :redis => @redis)
241
- entities.should be_an(Array)
242
- entities.should have(1).entity
243
- entities.first.should == 'def-456'
241
+ expect(entities).to be_an(Array)
242
+ expect(entities.size).to eq(1)
243
+ expect(entities.first).to eq('def-456')
244
244
  end
245
245
 
246
246
  end
@@ -23,56 +23,56 @@ describe Flapjack::Data::Event do
23
23
  context 'class' do
24
24
 
25
25
  it "returns the next event (blocking, archiving)" do
26
- mock_redis.should_receive(:brpoplpush).with('events', /^events_archive:/, 0).and_return(event_data.to_json)
27
- mock_redis.should_receive(:expire)
26
+ expect(mock_redis).to receive(:brpoplpush).with('events', /^events_archive:/, 0).and_return(event_data.to_json)
27
+ expect(mock_redis).to receive(:expire)
28
28
 
29
29
  result = Flapjack::Data::Event.next('events', :block => true, :archive_events => true, :redis => mock_redis)
30
- result.should be_an_instance_of(Flapjack::Data::Event)
30
+ expect(result).to be_an_instance_of(Flapjack::Data::Event)
31
31
  end
32
32
 
33
33
  it "returns the next event (blocking, not archiving)" do
34
- mock_redis.should_receive(:brpop).with('events', 0).and_return(['events', event_data.to_json])
34
+ expect(mock_redis).to receive(:brpop).with('events', 0).and_return(['events', event_data.to_json])
35
35
 
36
36
  result = Flapjack::Data::Event.next('events', :block => true, :archive_events => false, :redis => mock_redis)
37
- result.should be_an_instance_of(Flapjack::Data::Event)
37
+ expect(result).to be_an_instance_of(Flapjack::Data::Event)
38
38
  end
39
39
 
40
40
  it "returns the next event (non-blocking, archiving)" do
41
- mock_redis.should_receive(:rpoplpush).with('events', /^events_archive:/).and_return(event_data.to_json)
42
- mock_redis.should_receive(:expire)
41
+ expect(mock_redis).to receive(:rpoplpush).with('events', /^events_archive:/).and_return(event_data.to_json)
42
+ expect(mock_redis).to receive(:expire)
43
43
 
44
44
  result = Flapjack::Data::Event.next('events', :block => false, :archive_events => true, :redis => mock_redis)
45
- result.should be_an_instance_of(Flapjack::Data::Event)
45
+ expect(result).to be_an_instance_of(Flapjack::Data::Event)
46
46
  end
47
47
 
48
48
  it "returns the next event (non-blocking, not archiving)" do
49
- mock_redis.should_receive(:rpop).with('events').and_return(event_data.to_json)
49
+ expect(mock_redis).to receive(:rpop).with('events').and_return(event_data.to_json)
50
50
 
51
51
  result = Flapjack::Data::Event.next('events', :block => false, :archive_events => false, :redis => mock_redis)
52
- result.should be_an_instance_of(Flapjack::Data::Event)
52
+ expect(result).to be_an_instance_of(Flapjack::Data::Event)
53
53
  end
54
54
 
55
55
  it "handles invalid event JSON"
56
56
 
57
57
  it "returns a count of pending events" do
58
58
  events_len = 23
59
- mock_redis.should_receive(:llen).with('events').and_return(events_len)
59
+ expect(mock_redis).to receive(:llen).with('events').and_return(events_len)
60
60
 
61
61
  pc = Flapjack::Data::Event.pending_count('events', :redis => mock_redis)
62
- pc.should == events_len
62
+ expect(pc).to eq(events_len)
63
63
  end
64
64
 
65
65
  it "creates a notification testing event" do
66
- Time.should_receive(:now).and_return(time)
67
- mock_redis.should_receive(:lpush).with('events', /"testing"/ )
66
+ expect(Time).to receive(:now).and_return(time)
67
+ expect(mock_redis).to receive(:lpush).with('events', /"testing"/ )
68
68
 
69
69
  Flapjack::Data::Event.test_notifications(entity_name, check,
70
70
  :summary => 'test', :details => 'testing', :redis => mock_redis)
71
71
  end
72
72
 
73
73
  it "creates an acknowledgement event" do
74
- Time.should_receive(:now).and_return(time)
75
- mock_redis.should_receive(:lpush).with('events', /"acking"/ )
74
+ expect(Time).to receive(:now).and_return(time)
75
+ expect(mock_redis).to receive(:lpush).with('events', /"acking"/ )
76
76
 
77
77
  Flapjack::Data::Event.create_acknowledgement(entity_name, check,
78
78
  :summary => 'acking', :time => time.to_i, :redis => mock_redis)
@@ -81,20 +81,24 @@ describe Flapjack::Data::Event do
81
81
  end
82
82
 
83
83
  context 'instance' do
84
- subject { Flapjack::Data::Event.new(event_data) }
85
-
86
- its(:entity) { should == event_data['entity'] }
87
- its(:state) { should == event_data['state'] }
88
- its(:duration) { should == event_data['duration'] }
89
- its(:time) { should == event_data['time'] }
90
- its(:id) { should == 'xyz-example.com:ping' }
91
- its(:type) { should == 'service' }
92
-
93
- it { should be_a_service }
94
- it { should_not be_a_acknowledgement }
95
- it { should_not be_a_test_notifications }
96
- it { should_not be_ok }
97
- it { should be_a_failure }
84
+ let(:event) { Flapjack::Data::Event.new(event_data) }
85
+
86
+ it "matches the data it is initialised with" do
87
+ expect(event.entity).to eq(event_data['entity'])
88
+ expect(event.state).to eq(event_data['state'])
89
+ expect(event.duration).to eq(event_data['duration'])
90
+ expect(event.time).to eq(event_data['time'])
91
+ expect(event.id).to eq('xyz-example.com:ping')
92
+ expect(event.type).to eq('service')
93
+
94
+ expect(event).to be_a_service
95
+ expect(event).to be_a_service
96
+ expect(event).not_to be_an_acknowledgement
97
+ expect(event).not_to be_a_test_notifications
98
+ expect(event).not_to be_ok
99
+ expect(event).to be_a_failure
100
+ end
101
+
98
102
  end
99
103
 
100
104
  end
@@ -8,19 +8,19 @@ describe Flapjack::Data::Message do
8
8
  it "assigns itself an ID" do
9
9
  message = Flapjack::Data::Message.for_contact(contact)
10
10
  mid = message.id
11
- mid.should_not be_nil
12
- mid.should be_a(String)
11
+ expect(mid).not_to be_nil
12
+ expect(mid).to be_a(String)
13
13
  end
14
14
 
15
15
  it "returns its contained data" do
16
16
  message = Flapjack::Data::Message.for_contact(contact, :medium => 'email',
17
17
  :address => 'jja@example.com')
18
18
 
19
- contact.should_receive(:id).and_return('23')
20
- contact.should_receive(:first_name).and_return('James')
21
- contact.should_receive(:last_name).and_return('Jameson')
19
+ expect(contact).to receive(:id).and_return('23')
20
+ expect(contact).to receive(:first_name).and_return('James')
21
+ expect(contact).to receive(:last_name).and_return('Jameson')
22
22
 
23
- message.contents.should include('contact_id' => '23',
23
+ expect(message.contents).to include('contact_id' => '23',
24
24
  'contact_first_name' => 'James',
25
25
  'contact_last_name' => 'Jameson',
26
26
  'media' => 'email',
@@ -35,18 +35,18 @@ describe Flapjack::Data::NotificationRule, :redis => true do
35
35
  }
36
36
 
37
37
  it "checks that a notification rule exists" do
38
- Flapjack::Data::NotificationRule.exists_with_id?(existing_rule.id, :redis => @redis).should be_true
39
- Flapjack::Data::NotificationRule.exists_with_id?('not_there', :redis => @redis).should be_false
38
+ expect(Flapjack::Data::NotificationRule.exists_with_id?(existing_rule.id, :redis => @redis)).to be true
39
+ expect(Flapjack::Data::NotificationRule.exists_with_id?('not_there', :redis => @redis)).to be false
40
40
  end
41
41
 
42
42
  it "returns a notification rule if it exists" do
43
43
  rule = Flapjack::Data::NotificationRule.find_by_id(existing_rule.id, :redis => @redis)
44
- rule.should_not be_nil
44
+ expect(rule).not_to be_nil
45
45
  end
46
46
 
47
47
  it "does not return a notification rule if it does not exist" do
48
48
  rule = Flapjack::Data::NotificationRule.find_by_id('not_there', :redis => @redis)
49
- rule.should be_nil
49
+ expect(rule).to be_nil
50
50
  end
51
51
 
52
52
  it "updates a notification rule" do
@@ -55,50 +55,50 @@ describe Flapjack::Data::NotificationRule, :redis => true do
55
55
  expect {
56
56
  rule_data[:warning_blackhole] = true
57
57
  errors = rule.update(rule_data)
58
- errors.should be_nil
58
+ expect(errors).to be_nil
59
59
  }.to change { rule.warning_blackhole }.from(false).to(true)
60
60
  end
61
61
 
62
62
  it "converts time restriction data to an IceCube schedule" do
63
63
  sched = Flapjack::Data::NotificationRule.
64
64
  time_restriction_to_icecube_schedule(weekdays_8_18, timezone)
65
- sched.should_not be_nil
65
+ expect(sched).not_to be_nil
66
66
  end
67
67
 
68
68
  it "generates a JSON string representing its data" do
69
69
  rule = existing_rule
70
70
  # bit of extra hackery for the inserted ID values
71
- rule.to_json.should == {:id => rule.id}.merge(rule_data).to_json
71
+ expect(rule.to_json).to eq({:id => rule.id}.merge(rule_data).to_json)
72
72
  end
73
73
 
74
74
  it "checks whether entity names match" do
75
75
  rule = existing_rule
76
76
 
77
- rule.match_entity?('foo-app-01.example.com').should be_true
78
- rule.match_entity?('foo-app-02.example.com').should be_false
77
+ expect(rule.match_entity?('foo-app-01.example.com')).to be true
78
+ expect(rule.match_entity?('foo-app-02.example.com')).to be false
79
79
  end
80
80
 
81
81
  it "checks whether entity tags match" do
82
82
  rule = existing_rule
83
83
 
84
- rule.match_tags?(['database', 'physical'].to_set).should be_true
85
- rule.match_tags?(['database', 'physical', 'beetroot'].to_set).should be_true
86
- rule.match_tags?(['database'].to_set).should be_false
87
- rule.match_tags?(['virtual'].to_set).should be_false
84
+ expect(rule.match_tags?(['database', 'physical'].to_set)).to be true
85
+ expect(rule.match_tags?(['database', 'physical', 'beetroot'].to_set)).to be true
86
+ expect(rule.match_tags?(['database'].to_set)).to be false
87
+ expect(rule.match_tags?(['virtual'].to_set)).to be false
88
88
  end
89
89
 
90
90
  it "checks if blackhole settings for a rule match a severity level" do
91
91
  rule_data[:warning_blackhole] = true
92
92
  rule = Flapjack::Data::NotificationRule.add(rule_data, :redis => @redis)
93
93
 
94
- rule.blackhole?('warning').should be_true
95
- rule.blackhole?('critical').should be_false
94
+ expect(rule.blackhole?('warning')).to be true
95
+ expect(rule.blackhole?('critical')).to be false
96
96
  end
97
97
 
98
98
  it "returns the media settings for a rule's severity level" do
99
99
  rule = existing_rule
100
- rule.media_for_severity('warning').should == ['email']
101
- rule.media_for_severity('critical').should =~ ['email', 'sms']
100
+ expect(rule.media_for_severity('warning')).to eq(['email'])
101
+ expect(rule.media_for_severity('critical')).to match_array(['email', 'sms'])
102
102
  end
103
103
 
104
104
  context 'validation' do
@@ -106,10 +106,10 @@ describe Flapjack::Data::NotificationRule, :redis => true do
106
106
  it "fails to add a notification rule with invalid data" do
107
107
  rule_data[:entities] = [1, {}]
108
108
  rule_or_errors = Flapjack::Data::NotificationRule.add(rule_data, :redis => @redis)
109
- rule_or_errors.should_not be_nil
110
- rule_or_errors.should be_an(Array)
111
- rule_or_errors.should have(1).error
112
- rule_or_errors.should == ["Rule entities must be a list of strings"]
109
+ expect(rule_or_errors).not_to be_nil
110
+ expect(rule_or_errors).to be_an(Array)
111
+ expect(rule_or_errors.size).to eq(1)
112
+ expect(rule_or_errors).to eq(["Rule entities must be a list of strings"])
113
113
  end
114
114
 
115
115
  it "fails to update a notification rule with invalid data" do
@@ -117,9 +117,9 @@ describe Flapjack::Data::NotificationRule, :redis => true do
117
117
  expect {
118
118
  rule_data[:entities] = [57]
119
119
  errors = rule.update(rule_data)
120
- errors.should_not be_nil
121
- errors.should have(1).error
122
- errors.should == ["Rule entities must be a list of strings"]
120
+ expect(errors).not_to be_nil
121
+ expect(errors.size).to eq(1)
122
+ expect(errors).to eq(["Rule entities must be a list of strings"])
123
123
  }.not_to change { rule.entities }
124
124
  end
125
125