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
@@ -8,7 +8,7 @@ describe 'web/views/check.html.erb', :erb_view => true do
8
8
  @last_notifications = {}
9
9
 
10
10
  page = render_erb('check.html.erb', binding)
11
- page.should match(%r{/abc-xyz-01/Disk%20%2F%20Utilisation})
11
+ expect(page).to match(%r{/abc-xyz-01/Disk%20%2F%20Utilisation})
12
12
  end
13
13
 
14
14
  end
@@ -4,19 +4,19 @@ describe 'web/views/contact.html.erb', :erb_view => true do
4
4
 
5
5
  it "should escape unsafe check characters in URI parameters" do
6
6
  @contact = double('contact')
7
- @contact.should_receive(:media)
8
- @contact.should_receive(:name).twice.and_return('Aeschylus')
9
- @contact.should_receive(:notification_rules)
7
+ expect(@contact).to receive(:media)
8
+ expect(@contact).to receive(:name).and_return('Aeschylus')
9
+ expect(@contact).to receive(:notification_rules)
10
10
 
11
11
  entity = double('entity')
12
- entity.should_receive(:name).exactly(3).times.and_return('abc-xyz-01')
12
+ expect(entity).to receive(:name).exactly(3).times.and_return('abc-xyz-01')
13
13
 
14
14
  checks = ['Disk / Utilisation']
15
15
 
16
16
  @entities_and_checks = [{:entity => entity, :checks => checks}]
17
17
 
18
18
  page = render_erb('contact.html.erb', binding)
19
- page.should match(%r{\?entity=abc-xyz-01&check=Disk%20%2F%20Utilisation})
19
+ expect(page).to match(%r{\?entity=abc-xyz-01&check=Disk%20%2F%20Utilisation})
20
20
  end
21
21
 
22
22
  end
@@ -8,7 +8,7 @@ describe 'web/views/checks.html.erb', :erb_view => true do
8
8
  @adjective = "all"
9
9
 
10
10
  page = render_erb('checks.html.erb', binding)
11
- page.should match(%r{\?entity=abc-xyz-01&check=Disk%20%2F%20Utilisation})
11
+ expect(page).to match(%r{\?entity=abc-xyz-01&check=Disk%20%2F%20Utilisation})
12
12
  end
13
13
 
14
14
  end
@@ -24,49 +24,49 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
24
24
  end
25
25
 
26
26
  before(:each) do
27
- Flapjack::RedisPool.should_receive(:new).and_return(redis)
27
+ expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
28
28
  Flapjack::Gateways::Web.instance_variable_set('@config', {})
29
29
  Flapjack::Gateways::Web.instance_variable_set('@logger', @logger)
30
30
  Flapjack::Gateways::Web.start
31
31
  end
32
32
 
33
33
  def expect_stats
34
- redis.should_receive(:dbsize).and_return(3)
35
- redis.should_receive(:keys).with('executive_instance:*').and_return(["executive_instance:foo-app-01"])
36
- redis.should_receive(:hget).once.and_return(Time.now.to_i - 60)
37
- redis.should_receive(:hgetall).twice.and_return({'all' => '8001', 'ok' => '8002'},
34
+ expect(redis).to receive(:dbsize).and_return(3)
35
+ expect(redis).to receive(:keys).with('executive_instance:*').and_return(["executive_instance:foo-app-01"])
36
+ expect(redis).to receive(:hget).once.and_return(Time.now.to_i - 60)
37
+ expect(redis).to receive(:hgetall).twice.and_return({'all' => '8001', 'ok' => '8002'},
38
38
  {'all' => '9001', 'ok' => '9002'})
39
- redis.should_receive(:llen).with('events')
40
- redis.should_receive(:zrange).with('current_entities', 0, -1).and_return(['foo-app-01.example.com'])
41
- redis.should_receive(:zrange).with('current_checks:foo-app-01.example.com', 0, -1, {:withscores => true}).and_return([['ping', 1382329923.0]])
39
+ expect(redis).to receive(:llen).with('events')
40
+ expect(redis).to receive(:zrange).with('current_entities', 0, -1).and_return(['foo-app-01.example.com'])
41
+ expect(redis).to receive(:zrange).with('current_checks:foo-app-01.example.com', 0, -1, {:withscores => true}).and_return([['ping', 1382329923.0]])
42
42
  end
43
43
 
44
44
  def expect_check_stats
45
- Flapjack::Data::EntityCheck.should_receive(:count_all).
45
+ expect(Flapjack::Data::EntityCheck).to receive(:count_all).
46
46
  with(:redis => redis).and_return(1)
47
- Flapjack::Data::EntityCheck.should_receive(:count_all_failing).
47
+ expect(Flapjack::Data::EntityCheck).to receive(:count_all_failing).
48
48
  with(:redis => redis).and_return(1)
49
49
  end
50
50
 
51
51
  def expect_entity_stats
52
- Flapjack::Data::Entity.should_receive(:find_all_with_checks).
52
+ expect(Flapjack::Data::Entity).to receive(:find_all_with_checks).
53
53
  with(:redis => redis).and_return([entity_name])
54
- Flapjack::Data::Entity.should_receive(:find_all_with_failing_checks).
54
+ expect(Flapjack::Data::Entity).to receive(:find_all_with_failing_checks).
55
55
  with(:redis => redis).and_return([entity_name])
56
56
  end
57
57
 
58
58
  def expect_entity_check_status(ec)
59
59
  time = Time.now.to_i
60
60
 
61
- ec.should_receive(:state).and_return('ok')
62
- ec.should_receive(:summary).and_return('happy results are returned')
63
- ec.should_receive(:last_update).and_return(time - (3 * 60 * 60))
64
- ec.should_receive(:last_change).and_return(time - (3 * 60 * 60))
65
- ec.should_receive(:last_notification_for_state).with(:problem).and_return({:timestamp => time - ((3 * 60 * 60) + (5 * 60))})
66
- ec.should_receive(:last_notification_for_state).with(:recovery).and_return({:timestamp => time - (3 * 60 * 60)})
67
- ec.should_receive(:last_notification_for_state).with(:acknowledgement).and_return({:timestamp => nil})
68
- ec.should_receive(:in_scheduled_maintenance?).and_return(false)
69
- ec.should_receive(:in_unscheduled_maintenance?).and_return(false)
61
+ expect(ec).to receive(:state).and_return('ok')
62
+ expect(ec).to receive(:summary).and_return('happy results are returned')
63
+ expect(ec).to receive(:last_update).and_return(time - (3 * 60 * 60))
64
+ expect(ec).to receive(:last_change).and_return(time - (3 * 60 * 60))
65
+ expect(ec).to receive(:last_notification_for_state).with(:problem).and_return({:timestamp => time - ((3 * 60 * 60) + (5 * 60))})
66
+ expect(ec).to receive(:last_notification_for_state).with(:recovery).and_return({:timestamp => time - (3 * 60 * 60)})
67
+ expect(ec).to receive(:last_notification_for_state).with(:acknowledgement).and_return({:timestamp => nil})
68
+ expect(ec).to receive(:in_scheduled_maintenance?).and_return(false)
69
+ expect(ec).to receive(:in_unscheduled_maintenance?).and_return(false)
70
70
  end
71
71
 
72
72
  # TODO add data, test that pages contain representations of it
@@ -74,20 +74,20 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
74
74
 
75
75
  it "shows a page listing all checks" do
76
76
  #redis.should_receive(:keys).with('*:*:states').and_return(["#{entity_name}:#{check}"])
77
- Flapjack::Data::EntityCheck.should_receive(:find_all_by_entity).
77
+ expect(Flapjack::Data::EntityCheck).to receive(:find_all_by_entity).
78
78
  with(:redis => redis).and_return({entity_name => [check]})
79
79
  expect_check_stats
80
80
 
81
81
  expect_entity_check_status(entity_check)
82
82
 
83
- Flapjack::Data::Entity.should_receive(:find_by_name).
83
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
84
84
  with(entity_name, :redis => redis).and_return(entity)
85
85
 
86
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
86
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
87
87
  with(entity, 'ping', :redis => redis).and_return(entity_check)
88
88
 
89
89
  aget '/checks_all'
90
- last_response.should be_ok
90
+ expect(last_response).to be_ok
91
91
  end
92
92
 
93
93
  it "shows a page listing failing checks" do
@@ -97,16 +97,16 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
97
97
 
98
98
  expect_entity_check_status(entity_check)
99
99
 
100
- Flapjack::Data::Entity.should_receive(:find_by_name).
100
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
101
101
  with(entity_name, :redis => redis).and_return(entity)
102
102
 
103
- Flapjack::Data::EntityCheck.should_receive(:find_all_failing_by_entity).
103
+ expect(Flapjack::Data::EntityCheck).to receive(:find_all_failing_by_entity).
104
104
  with(:redis => redis).and_return({entity_name => [check]})
105
105
 
106
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
106
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
107
107
  with(entity, 'ping', :redis => redis).and_return(entity_check)
108
108
  aget '/checks_failing'
109
- last_response.should be_ok
109
+ expect(last_response).to be_ok
110
110
  end
111
111
 
112
112
  it "shows a page listing flapjack statistics" do
@@ -117,75 +117,74 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
117
117
  expect_entity_stats
118
118
 
119
119
  aget '/self_stats'
120
- last_response.should be_ok
120
+ expect(last_response).to be_ok
121
121
  end
122
122
 
123
123
  it "shows the state of a check for an entity" do
124
124
  time = Time.now
125
- Time.should_receive(:now).exactly(5).times.and_return(time)
125
+ expect(Time).to receive(:now).exactly(5).times.and_return(time)
126
126
 
127
127
  last_notifications = {:problem => {:timestamp => time.to_i - ((3 * 60 * 60) + (5 * 60)), :summary => 'prob'},
128
128
  :recovery => {:timestamp => time.to_i - (3 * 60 * 60), :summary => nil},
129
129
  :acknowledgement => {:timestamp => nil, :summary => nil} }
130
130
 
131
131
  expect_check_stats
132
- entity_check.should_receive(:state).and_return('ok')
133
- entity_check.should_receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
134
- entity_check.should_receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
135
- entity_check.should_receive(:summary).and_return('all good')
136
- entity_check.should_receive(:details).and_return('seriously, all very wonderful')
137
- entity_check.should_receive(:last_notifications_of_each_type).and_return(last_notifications)
138
- entity_check.should_receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
139
- entity_check.should_receive(:failed?).and_return(false)
140
- entity_check.should_receive(:current_maintenance).with(:scheduled => true).and_return(false)
141
- entity_check.should_receive(:current_maintenance).with(:scheduled => false).and_return(false)
142
- entity_check.should_receive(:contacts).and_return([])
143
- entity_check.should_receive(:historical_states).
132
+ expect(entity_check).to receive(:state).and_return('ok')
133
+ expect(entity_check).to receive(:last_update).and_return(time.to_i - (3 * 60 * 60))
134
+ expect(entity_check).to receive(:last_change).and_return(time.to_i - (3 * 60 * 60))
135
+ expect(entity_check).to receive(:summary).and_return('all good')
136
+ expect(entity_check).to receive(:details).and_return('seriously, all very wonderful')
137
+ expect(entity_check).to receive(:last_notifications_of_each_type).and_return(last_notifications)
138
+ expect(entity_check).to receive(:maintenances).with(nil, nil, :scheduled => true).and_return([])
139
+ expect(entity_check).to receive(:failed?).and_return(false)
140
+ expect(entity_check).to receive(:current_maintenance).with(:scheduled => true).and_return(false)
141
+ expect(entity_check).to receive(:current_maintenance).with(:scheduled => false).and_return(false)
142
+ expect(entity_check).to receive(:contacts).and_return([])
143
+ expect(entity_check).to receive(:historical_states).
144
144
  with(nil, time.to_i, :order => 'desc', :limit => 20).and_return([])
145
- entity_check.should_receive(:enabled?).with().
146
- and_return(true)
145
+ expect(entity_check).to receive(:enabled?).and_return(true)
147
146
 
148
- Flapjack::Data::Entity.should_receive(:find_by_name).
147
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
149
148
  with(entity_name, :redis => redis).and_return(entity)
150
149
 
151
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
150
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
152
151
  with(entity, 'ping', :redis => redis).and_return(entity_check)
153
152
 
154
153
  aget "/check?entity=#{entity_name_esc}&check=ping"
155
- last_response.should be_ok
154
+ expect(last_response).to be_ok
156
155
  # TODO test instance variables set to appropriate values
157
156
  end
158
157
 
159
158
  it "returns 404 if an unknown entity is requested" do
160
- Flapjack::Data::Entity.should_receive(:find_by_name).
159
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
161
160
  with(entity_name_esc, :redis => redis).and_return(nil)
162
161
 
163
162
  aget "/check?entity=#{entity_name_esc}&check=ping"
164
- last_response.should be_not_found
163
+ expect(last_response).to be_not_found
165
164
  end
166
165
 
167
166
  # TODO shouldn't create actual entity record
168
167
  it "returns 404 if no entity check is passed" do
169
- Flapjack::Data::Entity.should_receive(:find_by_name).
168
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
170
169
  with(entity_name, :redis => redis).and_return(entity)
171
170
 
172
171
  aget "/check?entity=#{entity_name_esc}"
173
- last_response.should be_not_found
172
+ expect(last_response).to be_not_found
174
173
  end
175
174
 
176
175
  it "creates an acknowledgement for an entity check" do
177
- Flapjack::Data::Entity.should_receive(:find_by_name).
176
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
178
177
  with(entity_name, :redis => redis).and_return(entity)
179
178
 
180
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
179
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
181
180
  with(entity, 'ping', :redis => redis).and_return(entity_check)
182
181
 
183
- Flapjack::Data::Event.should_receive(:create_acknowledgement).
182
+ expect(Flapjack::Data::Event).to receive(:create_acknowledgement).
184
183
  with(entity_name, 'ping', :summary => "", :duration => (4 * 60 * 60),
185
184
  :acknowledgement_id => '1234', :redis => redis)
186
185
 
187
186
  apost "/acknowledgements/#{entity_name_esc}/ping?acknowledgement_id=1234"
188
- last_response.status.should == 302
187
+ expect(last_response.status).to eq(302)
189
188
  end
190
189
 
191
190
  it "creates a scheduled maintenance period for an entity check" do
@@ -195,22 +194,22 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
195
194
  duration = 30 * 60
196
195
  summary = 'wow'
197
196
 
198
- Chronic.should_receive(:parse).with('1 day ago').and_return(start_time)
199
- ChronicDuration.should_receive(:parse).with('30 minutes').and_return(duration)
197
+ expect(Chronic).to receive(:parse).with('1 day ago').and_return(start_time)
198
+ expect(ChronicDuration).to receive(:parse).with('30 minutes').and_return(duration)
200
199
 
201
- Flapjack::Data::Entity.should_receive(:find_by_name).
200
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
202
201
  with(entity_name, :redis => redis).and_return(entity)
203
202
 
204
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
203
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
205
204
  with(entity, 'ping', :redis => redis).and_return(entity_check)
206
205
 
207
- entity_check.should_receive(:create_scheduled_maintenance).
206
+ expect(entity_check).to receive(:create_scheduled_maintenance).
208
207
  with(start_time.to_i, duration, :summary => summary)
209
208
 
210
209
  apost "/scheduled_maintenances/#{entity_name_esc}/ping?"+
211
210
  "start_time=1+day+ago&duration=30+minutes&summary=wow"
212
211
 
213
- last_response.status.should == 302
212
+ expect(last_response.status).to eq(302)
214
213
  end
215
214
 
216
215
  it "deletes a scheduled maintenance period for an entity check" do
@@ -218,37 +217,37 @@ describe Flapjack::Gateways::Web, :sinatra => true, :logger => true do
218
217
 
219
218
  start_time = t - (24 * 60 * 60)
220
219
 
221
- Flapjack::Data::Entity.should_receive(:find_by_name).
220
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
222
221
  with(entity_name, :redis => redis).and_return(entity)
223
222
 
224
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
223
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
225
224
  with(entity, 'ping', :redis => redis).and_return(entity_check)
226
225
 
227
- entity_check.should_receive(:end_scheduled_maintenance).with(start_time)
226
+ expect(entity_check).to receive(:end_scheduled_maintenance).with(start_time)
228
227
 
229
228
  adelete "/scheduled_maintenances/#{entity_name_esc}/ping?start_time=#{start_time}"
230
- last_response.status.should == 302
229
+ expect(last_response.status).to eq(302)
231
230
  end
232
231
 
233
232
  it "shows a list of all known contacts" do
234
- Flapjack::Data::Contact.should_receive(:all)
233
+ expect(Flapjack::Data::Contact).to receive(:all)
235
234
 
236
235
  aget "/contacts"
237
- last_response.should be_ok
236
+ expect(last_response).to be_ok
238
237
  end
239
238
 
240
239
  it "shows details of an individual contact found by id" do
241
240
  contact = double('contact')
242
- contact.should_receive(:name).twice.and_return("Smithson Smith")
243
- contact.should_receive(:media).exactly(3).times.and_return({})
244
- contact.should_receive(:entities).with(:checks => true).and_return([])
245
- contact.should_receive(:notification_rules).and_return([])
241
+ expect(contact).to receive(:name).and_return("Smithson Smith")
242
+ expect(contact).to receive(:media).exactly(3).times.and_return({})
243
+ expect(contact).to receive(:entities).with(:checks => true).and_return([])
244
+ expect(contact).to receive(:notification_rules).and_return([])
246
245
 
247
- Flapjack::Data::Contact.should_receive(:find_by_id).
246
+ expect(Flapjack::Data::Contact).to receive(:find_by_id).
248
247
  with('0362', :redis => redis).and_return(contact)
249
248
 
250
249
  aget "/contacts/0362"
251
- last_response.should be_ok
250
+ expect(last_response).to be_ok
252
251
  end
253
252
 
254
253
  end
@@ -9,29 +9,29 @@ describe Flapjack::Logger do
9
9
  let(:syslog) { double(Syslog) }
10
10
 
11
11
  it "creates a logger logging to STDOUT and syslog" do
12
- logger.should_receive(:formatter=).with(an_instance_of(Proc))
13
- logger.should_receive(:level=).and_return(Logger::DEBUG)
14
- logger.should_receive(:add).with(2, nil, "Yowza!")
15
- ::Logger.should_receive(:new).with(STDOUT).and_return(logger)
12
+ expect(logger).to receive(:formatter=).with(an_instance_of(Proc))
13
+ expect(logger).to receive(:level=).and_return(Logger::DEBUG)
14
+ expect(logger).to receive(:add).with(2, nil, "Yowza!")
15
+ expect(::Logger).to receive(:new).with(STDOUT).and_return(logger)
16
16
 
17
- Syslog.should_receive(:open).with('flapjack',
17
+ expect(Syslog).to receive(:open).with('flapjack',
18
18
  (Syslog::Constants::LOG_PID | Syslog::Constants::LOG_CONS),
19
19
  Syslog::Constants::LOG_USER).and_return(syslog)
20
- Syslog.should_receive(:mask=).with(Syslog::LOG_UPTO(Syslog::Constants::LOG_ERR))
21
- Syslog.should_receive(:log).with(Syslog::Constants::LOG_WARNING, /\[WARN\] :: spec :: %s/, "Yowza!")
22
- Syslog.should_receive(:close)
20
+ expect(Syslog).to receive(:mask=).with(Syslog::LOG_UPTO(Syslog::Constants::LOG_ERR))
21
+ expect(Syslog).to receive(:log).with(Syslog::Constants::LOG_WARNING, /\[WARN\] :: spec :: %s/, "Yowza!")
22
+ expect(Syslog).to receive(:close)
23
23
 
24
24
  flogger = Flapjack::Logger.new('spec', 'level' => 'debug', 'syslog_errors' => 'true')
25
25
  flogger.warn "Yowza!"
26
26
  end
27
27
 
28
28
  it 'defaults to not logging via syslog' do
29
- logger.should_receive(:formatter=).with(an_instance_of(Proc))
30
- logger.should_receive(:level=).and_return(Logger::DEBUG)
31
- logger.should_receive(:add).with(2, nil, "Yowza!")
32
- ::Logger.should_receive(:new).with(STDOUT).and_return(logger)
29
+ expect(logger).to receive(:formatter=).with(an_instance_of(Proc))
30
+ expect(logger).to receive(:level=).and_return(Logger::DEBUG)
31
+ expect(logger).to receive(:add).with(2, nil, "Yowza!")
32
+ expect(::Logger).to receive(:new).with(STDOUT).and_return(logger)
33
33
 
34
- Syslog.should_not_receive(:open)
34
+ expect(Syslog).not_to receive(:open)
35
35
 
36
36
  flogger = Flapjack::Logger.new('spec', 'level' => 'debug')
37
37
  flogger.warn "Yowza!"
@@ -17,86 +17,86 @@ describe Flapjack::Pikelet do
17
17
  end
18
18
 
19
19
  it "creates and starts a processor pikelet" do
20
- Flapjack::Logger.should_receive(:new).and_return(logger)
20
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
21
21
 
22
- config.should_receive(:[]).with('logger').and_return(nil)
22
+ expect(config).to receive(:[]).with('logger').and_return(nil)
23
23
 
24
24
  fc = double('coordinator')
25
25
 
26
26
  processor = double('processor')
27
- processor.should_receive(:start)
28
- Flapjack::Processor.should_receive(:new).with(:config => config,
27
+ expect(processor).to receive(:start)
28
+ expect(Flapjack::Processor).to receive(:new).with(:config => config,
29
29
  :redis_config => redis_config, :boot_time => time, :logger => logger, :coordinator => fc).
30
30
  and_return(processor)
31
31
 
32
- fiber.should_receive(:resume)
33
- Fiber.should_receive(:new).and_yield.and_return(fiber)
32
+ expect(fiber).to receive(:resume)
33
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
34
34
 
35
35
  pik = Flapjack::Pikelet.create('processor', :config => config,
36
36
  :redis_config => redis_config, :boot_time => time, :coordinator => fc)
37
- pik.should be_a(Flapjack::Pikelet::Generic)
37
+ expect(pik).to be_a(Flapjack::Pikelet::Generic)
38
38
  pik.start
39
39
  end
40
40
 
41
41
  it "creates and starts a resque worker gateway" do
42
- Flapjack::Logger.should_receive(:new).and_return(logger)
42
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
43
43
 
44
- config.should_receive(:[]).with('logger').and_return(nil)
45
- config.should_receive(:[]).with('queue').and_return('email_notif')
44
+ expect(config).to receive(:[]).with('logger').and_return(nil)
45
+ expect(config).to receive(:[]).with('queue').and_return('email_notif')
46
46
 
47
47
  resque_redis = double('resque_redis')
48
48
  redis = double('redis')
49
- Flapjack::RedisPool.should_receive(:new).twice.and_return(resque_redis, redis)
50
- Resque.should_receive(:redis=).with(resque_redis)
49
+ expect(Flapjack::RedisPool).to receive(:new).twice.and_return(resque_redis, redis)
50
+ expect(Resque).to receive(:redis=).with(resque_redis)
51
51
 
52
- Flapjack::Gateways::Email.should_receive(:instance_variable_set).
52
+ expect(Flapjack::Gateways::Email).to receive(:instance_variable_set).
53
53
  with('@config', config)
54
- Flapjack::Gateways::Email.should_receive(:instance_variable_set).
54
+ expect(Flapjack::Gateways::Email).to receive(:instance_variable_set).
55
55
  with('@redis', redis)
56
- Flapjack::Gateways::Email.should_receive(:instance_variable_set).
56
+ expect(Flapjack::Gateways::Email).to receive(:instance_variable_set).
57
57
  with('@logger', logger)
58
58
 
59
59
  worker = double('worker')
60
- worker.should_receive(:work).with(0.1)
61
- Flapjack::Gateways::Email.should_receive(:start)
62
- EM::Resque::Worker.should_receive(:new).with('email_notif').and_return(worker)
60
+ expect(worker).to receive(:work).with(0.1)
61
+ expect(Flapjack::Gateways::Email).to receive(:start)
62
+ expect(EM::Resque::Worker).to receive(:new).with('email_notif').and_return(worker)
63
63
 
64
- fiber.should_receive(:resume)
65
- Fiber.should_receive(:new).and_yield.and_return(fiber)
64
+ expect(fiber).to receive(:resume)
65
+ expect(Fiber).to receive(:new).and_yield.and_return(fiber)
66
66
 
67
67
  pik = Flapjack::Pikelet.create('email', :config => config,
68
68
  :redis_config => redis_config)
69
- pik.should be_a(Flapjack::Pikelet::Resque)
69
+ expect(pik).to be_a(Flapjack::Pikelet::Resque)
70
70
  pik.start
71
71
  end
72
72
 
73
73
  it "creates a thin server gateway" do
74
- Flapjack::Logger.should_receive(:new).and_return(logger)
74
+ expect(Flapjack::Logger).to receive(:new).and_return(logger)
75
75
 
76
- config.should_receive(:[]).with('logger').and_return(nil)
77
- config.should_receive(:[]).with('port').and_return(7654)
78
- config.should_receive(:[]).with('timeout').and_return(90)
76
+ expect(config).to receive(:[]).with('logger').and_return(nil)
77
+ expect(config).to receive(:[]).with('port').and_return(7654)
78
+ expect(config).to receive(:[]).with('timeout').and_return(90)
79
79
 
80
80
  server = double('server')
81
- server.should_receive(:timeout=).with(90)
82
- server.should_receive(:start)
83
- Thin::Server.should_receive(:new).
81
+ expect(server).to receive(:timeout=).with(90)
82
+ expect(server).to receive(:start)
83
+ expect(Thin::Server).to receive(:new).
84
84
  with(/^(?:\d{1,3}\.){3}\d{1,3}$/, 7654,
85
85
  Flapjack::Gateways::Web, :signals => false).
86
86
  and_return(server)
87
87
 
88
- Flapjack::Gateways::Web.should_receive(:instance_variable_set).
88
+ expect(Flapjack::Gateways::Web).to receive(:instance_variable_set).
89
89
  with('@config', config)
90
- Flapjack::Gateways::Web.should_receive(:instance_variable_set).
90
+ expect(Flapjack::Gateways::Web).to receive(:instance_variable_set).
91
91
  with('@redis_config', redis_config)
92
- Flapjack::Gateways::Web.should_receive(:instance_variable_set).
92
+ expect(Flapjack::Gateways::Web).to receive(:instance_variable_set).
93
93
  with('@logger', logger)
94
94
 
95
- Flapjack::Gateways::Web.should_receive(:start)
95
+ expect(Flapjack::Gateways::Web).to receive(:start)
96
96
 
97
97
  pik = Flapjack::Pikelet.create('web', :config => config,
98
98
  :redis_config => redis_config)
99
- pik.should be_a(Flapjack::Pikelet::Thin)
99
+ expect(pik).to be_a(Flapjack::Pikelet::Thin)
100
100
  pik.start
101
101
  end
102
102