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
@@ -38,33 +38,33 @@ describe 'Flapjack::Gateways::API::EntityCheckPresenter' do
38
38
  }
39
39
 
40
40
  it "returns a list of outage hashes for an entity check" do
41
- entity_check.should_receive(:historical_states).
41
+ expect(entity_check).to receive(:historical_states).
42
42
  with(time - (5 * 60 * 60), time - (2 * 60 * 60)).and_return(states)
43
43
 
44
- entity_check.should_receive(:historical_state_before).
44
+ expect(entity_check).to receive(:historical_state_before).
45
45
  with(time - (4 * 60 * 60)).and_return(nil)
46
46
 
47
47
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
48
48
  outages = ecp.outages(time - (5 * 60 * 60), time - (2 * 60 * 60))
49
- outages.should_not be_nil
50
- outages.should be_an(Array)
51
- outages.should have(4).time_ranges
49
+ expect(outages).not_to be_nil
50
+ expect(outages).to be_an(Array)
51
+ expect(outages.size).to eq(4)
52
52
 
53
53
  # TODO check the data in those hashes
54
54
  end
55
55
 
56
56
  it "returns a list of outage hashes with no start and end time set" do
57
- entity_check.should_receive(:historical_states).
57
+ expect(entity_check).to receive(:historical_states).
58
58
  with(nil, nil).and_return(states)
59
59
 
60
- entity_check.should_receive(:historical_state_before).
60
+ expect(entity_check).to receive(:historical_state_before).
61
61
  with(time - (4 * 60 * 60)).and_return(nil)
62
62
 
63
63
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
64
64
  outages = ecp.outages(nil, nil)
65
- outages.should_not be_nil
66
- outages.should be_an(Array)
67
- outages.should have(4).time_ranges
65
+ expect(outages).not_to be_nil
66
+ expect(outages).to be_an(Array)
67
+ expect(outages.size).to eq(4)
68
68
 
69
69
  # TODO check the data in those hashes
70
70
  end
@@ -73,113 +73,113 @@ describe 'Flapjack::Gateways::API::EntityCheckPresenter' do
73
73
  states[1][:state] = 'critical'
74
74
  states[2][:state] = 'ok'
75
75
 
76
- entity_check.should_receive(:historical_states).
76
+ expect(entity_check).to receive(:historical_states).
77
77
  with(nil, nil).and_return(states)
78
78
 
79
- entity_check.should_receive(:historical_state_before).
79
+ expect(entity_check).to receive(:historical_state_before).
80
80
  with(time - (4 * 60 * 60)).and_return(nil)
81
81
 
82
82
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
83
83
  outages = ecp.outages(nil, nil)
84
- outages.should_not be_nil
85
- outages.should be_an(Array)
86
- outages.should have(3).time_ranges
84
+ expect(outages).not_to be_nil
85
+ expect(outages).to be_an(Array)
86
+ expect(outages.size).to eq(3)
87
87
  end
88
88
 
89
89
  it "returns a (small) outage hash for a single state change" do
90
- entity_check.should_receive(:historical_states).
90
+ expect(entity_check).to receive(:historical_states).
91
91
  with(nil, nil).and_return([{:state => 'critical', :timestamp => time - (4 * 60 * 60)}])
92
- entity_check.should_receive(:historical_state_before).
92
+ expect(entity_check).to receive(:historical_state_before).
93
93
  with(time - (4 * 60 * 60)).and_return(nil)
94
94
 
95
95
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
96
96
  outages = ecp.outages(nil, nil)
97
- outages.should_not be_nil
98
- outages.should be_an(Array)
99
- outages.should have(1).time_range
97
+ expect(outages).not_to be_nil
98
+ expect(outages).to be_an(Array)
99
+ expect(outages.size).to eq(1)
100
100
  end
101
101
 
102
102
  it "a list of unscheduled maintenances for an entity check" do
103
- entity_check.should_receive(:maintenances).
103
+ expect(entity_check).to receive(:maintenances).
104
104
  with(time - (12 * 60 * 60), time, :scheduled => false).and_return(maintenances)
105
105
 
106
- entity_check.should_receive(:maintenances).
106
+ expect(entity_check).to receive(:maintenances).
107
107
  with(nil, time - (12 * 60 * 60), :scheduled => false).and_return([])
108
108
 
109
109
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
110
110
  unsched_maint = ecp.unscheduled_maintenances(time - (12 * 60 * 60), time)
111
111
 
112
- unsched_maint.should be_an(Array)
113
- unsched_maint.should have(4).time_ranges
112
+ expect(unsched_maint).to be_an(Array)
113
+ expect(unsched_maint.size).to eq(4)
114
114
 
115
115
  # TODO check the data in those hashes
116
116
  end
117
117
 
118
118
  it "a list of scheduled maintenances for an entity check" do
119
- entity_check.should_receive(:maintenances).
119
+ expect(entity_check).to receive(:maintenances).
120
120
  with(time - (12 * 60 * 60), time, :scheduled => true).and_return(maintenances)
121
121
 
122
- entity_check.should_receive(:maintenances).
122
+ expect(entity_check).to receive(:maintenances).
123
123
  with(nil, time - (12 * 60 * 60), :scheduled => true).and_return([])
124
124
 
125
125
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
126
126
  sched_maint = ecp.scheduled_maintenances(time - (12 * 60 * 60), time)
127
127
 
128
- sched_maint.should be_an(Array)
129
- sched_maint.should have(4).time_ranges
128
+ expect(sched_maint).to be_an(Array)
129
+ expect(sched_maint.size).to eq(4)
130
130
 
131
131
  # TODO check the data in those hashes
132
132
  end
133
133
 
134
134
  it "returns downtime and percentage for a downtime check" do
135
- entity_check.should_receive(:historical_states).
135
+ expect(entity_check).to receive(:historical_states).
136
136
  with(time - (12 * 60 * 60), time).and_return(states)
137
137
 
138
- entity_check.should_receive(:historical_state_before).
138
+ expect(entity_check).to receive(:historical_state_before).
139
139
  with(time - (4 * 60 * 60)).and_return(nil)
140
140
 
141
- entity_check.should_receive(:maintenances).
141
+ expect(entity_check).to receive(:maintenances).
142
142
  with(time - (12 * 60 * 60), time, :scheduled => true).and_return(maintenances)
143
143
 
144
- entity_check.should_receive(:maintenances).
144
+ expect(entity_check).to receive(:maintenances).
145
145
  with(nil, time - (12 * 60 * 60), :scheduled => true).and_return([])
146
146
 
147
147
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
148
148
  downtimes = ecp.downtime(time - (12 * 60 * 60), time)
149
149
 
150
150
  # 22 minutes, 3 + 8 + 11
151
- downtimes.should be_a(Hash)
152
- downtimes[:total_seconds].should == {'critical' => (22 * 60),
153
- 'ok' => ((12 * 60 * 60) - (22 * 60))}
154
- downtimes[:percentages].should == {'critical' => (((22 * 60) * 100.0) / (12 * 60 * 60)),
155
- 'ok' => ((((12 * 60 * 60) - (22 * 60)) * 100.0) / (12 * 60 *60))}
156
- downtimes[:downtime].should be_an(Array)
151
+ expect(downtimes).to be_a(Hash)
152
+ expect(downtimes[:total_seconds]).to eq({'critical' => (22 * 60),
153
+ 'ok' => ((12 * 60 * 60) - (22 * 60))})
154
+ expect(downtimes[:percentages]).to eq({'critical' => (((22 * 60) * 100.0) / (12 * 60 * 60)),
155
+ 'ok' => ((((12 * 60 * 60) - (22 * 60)) * 100.0) / (12 * 60 *60))})
156
+ expect(downtimes[:downtime]).to be_an(Array)
157
157
  # the last outage gets split by the intervening maintenance period,
158
158
  # but the fully covered one gets removed.
159
- downtimes[:downtime].should have(4).time_ranges
159
+ expect(downtimes[:downtime].size).to eq(4)
160
160
  end
161
161
 
162
162
  it "returns downtime (but no percentage) for an unbounded downtime check" do
163
- entity_check.should_receive(:historical_states).
163
+ expect(entity_check).to receive(:historical_states).
164
164
  with(nil, nil).and_return(states)
165
165
 
166
- entity_check.should_receive(:historical_state_before).
166
+ expect(entity_check).to receive(:historical_state_before).
167
167
  with(time - (4 * 60 * 60)).and_return(nil)
168
168
 
169
- entity_check.should_receive(:maintenances).
169
+ expect(entity_check).to receive(:maintenances).
170
170
  with(nil, nil, :scheduled => true).and_return(maintenances)
171
171
 
172
172
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
173
173
  downtimes = ecp.downtime(nil, nil)
174
174
 
175
175
  # 22 minutes, 3 + 8 + 11
176
- downtimes.should be_a(Hash)
177
- downtimes[:total_seconds].should == {'critical' => (22 * 60)}
178
- downtimes[:percentages].should == {'critical' => nil}
179
- downtimes[:downtime].should be_an(Array)
176
+ expect(downtimes).to be_a(Hash)
177
+ expect(downtimes[:total_seconds]).to eq({'critical' => (22 * 60)})
178
+ expect(downtimes[:percentages]).to eq({'critical' => nil})
179
+ expect(downtimes[:downtime]).to be_an(Array)
180
180
  # the last outage gets split by the intervening maintenance period,
181
181
  # but the fully covered one gets removed.
182
- downtimes[:downtime].should have(4).time_ranges
182
+ expect(downtimes[:downtime].size).to eq(4)
183
183
  end
184
184
 
185
185
  it "returns downtime and handles an unfinished problem state" do
@@ -187,25 +187,25 @@ describe 'Flapjack::Gateways::API::EntityCheckPresenter' do
187
187
  {:state => 'ok', :timestamp => time - (4 * 60 * 60) + (5 * 60)},
188
188
  {:state => 'critical', :timestamp => time - (3 * 60 * 60)}]
189
189
 
190
- entity_check.should_receive(:historical_states).
190
+ expect(entity_check).to receive(:historical_states).
191
191
  with(nil, nil).and_return(current)
192
192
 
193
- entity_check.should_receive(:historical_state_before).
193
+ expect(entity_check).to receive(:historical_state_before).
194
194
  with(time - (4 * 60 * 60)).and_return(nil)
195
195
 
196
- entity_check.should_receive(:maintenances).
196
+ expect(entity_check).to receive(:maintenances).
197
197
  with(nil, nil, :scheduled => true).and_return([])
198
198
 
199
199
  ecp = Flapjack::Gateways::API::EntityCheckPresenter.new(entity_check)
200
200
  downtimes = ecp.downtime(nil, nil)
201
201
 
202
- downtimes.should be_a(Hash)
203
- downtimes[:total_seconds].should == {'critical' => (5 * 60)}
204
- downtimes[:percentages].should == {'critical' => nil}
205
- downtimes[:downtime].should be_an(Array)
202
+ expect(downtimes).to be_a(Hash)
203
+ expect(downtimes[:total_seconds]).to eq({'critical' => (5 * 60)})
204
+ expect(downtimes[:percentages]).to eq({'critical' => nil})
205
+ expect(downtimes[:downtime]).to be_an(Array)
206
206
  # the last outage gets split by the intervening maintenance period,
207
207
  # but the fully covered one gets removed.
208
- downtimes[:downtime].should have(2).time_ranges
208
+ expect(downtimes[:downtime].size).to eq(2)
209
209
  end
210
210
 
211
211
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'flapjack/gateways/api'
3
3
 
4
- describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger => true, :json => true do
4
+ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger => true do
5
5
 
6
6
  def app
7
7
  Flapjack::Gateways::API
@@ -26,20 +26,20 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
26
26
  end
27
27
 
28
28
  before(:each) do
29
- Flapjack::RedisPool.should_receive(:new).and_return(redis)
29
+ expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
30
30
  Flapjack::Gateways::API.instance_variable_set('@config', {})
31
31
  Flapjack::Gateways::API.instance_variable_set('@logger', @logger)
32
32
  Flapjack::Gateways::API.start
33
33
  end
34
34
 
35
35
  it "returns a list of checks for an entity" do
36
- entity.should_receive(:check_list).and_return([check])
37
- Flapjack::Data::Entity.should_receive(:find_by_name).
36
+ expect(entity).to receive(:check_list).and_return([check])
37
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
38
38
  with(entity_name, :redis => redis).and_return(entity)
39
39
 
40
40
  aget "/checks/#{entity_name_esc}"
41
- last_response.should be_ok
42
- last_response.body.should == [check].to_json
41
+ expect(last_response).to be_ok
42
+ expect(last_response.body).to eq([check].to_json)
43
43
  end
44
44
 
45
45
  context 'non-bulk API calls' do
@@ -47,76 +47,76 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
47
47
  it "returns the status for all checks on an entity" do
48
48
  status = double('status', :to_json => 'status!'.to_json)
49
49
  result = {:entity => entity_name, :check => check, :status => status}
50
- entity_presenter.should_receive(:status).and_return(result)
50
+ expect(entity_presenter).to receive(:status).and_return(result)
51
51
 
52
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
52
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
53
53
  with(entity, :redis => redis).and_return(entity_presenter)
54
54
 
55
- Flapjack::Data::Entity.should_receive(:find_by_name).
55
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
56
56
  with(entity_name, :redis => redis).and_return(entity)
57
57
 
58
58
  aget "/status/#{entity_name_esc}"
59
- last_response.should be_ok
60
- last_response.body.should == ['status!'].to_json
59
+ expect(last_response).to be_ok
60
+ expect(last_response.body).to eq(['status!'].to_json)
61
61
  end
62
62
 
63
63
  it "should not show the status for an entity that's not found" do
64
- Flapjack::Data::Entity.should_receive(:find_by_name).
64
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
65
65
  with(entity_name, :redis => redis).and_return(nil)
66
66
 
67
67
  aget "/status/#{entity_name_esc}"
68
- last_response.should be_forbidden
68
+ expect(last_response).to be_forbidden
69
69
  end
70
70
 
71
71
  it "returns the status for a check on an entity" do
72
72
  status = double('status', :to_json => 'status!'.to_json)
73
- entity_check_presenter.should_receive(:status).and_return(status)
73
+ expect(entity_check_presenter).to receive(:status).and_return(status)
74
74
 
75
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
75
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
76
76
  with(entity_check).and_return(entity_check_presenter)
77
77
 
78
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
78
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
79
79
  with(entity, check, :redis => redis).and_return(entity_check)
80
80
 
81
- Flapjack::Data::Entity.should_receive(:find_by_name).
81
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
82
82
  with(entity_name, :redis => redis).and_return(entity)
83
83
 
84
84
  aget "/status/#{entity_name_esc}/#{check}"
85
- last_response.should be_ok
86
- last_response.body.should == 'status!'.to_json
85
+ expect(last_response).to be_ok
86
+ expect(last_response.body).to eq('status!'.to_json)
87
87
  end
88
88
 
89
89
  it "should not show the status for a check on an entity that's not found" do
90
- Flapjack::Data::Entity.should_receive(:find_by_name).
90
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
91
91
  with(entity_name, :redis => redis).and_return(nil)
92
92
 
93
93
  aget "/status/#{entity_name_esc}/#{check}"
94
- last_response.should be_forbidden
94
+ expect(last_response).to be_forbidden
95
95
  end
96
96
 
97
97
  it "should not show the status for a check that's not found on an entity" do
98
- Flapjack::Data::Entity.should_receive(:find_by_name).
98
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
99
99
  with(entity_name, :redis => redis).and_return(entity)
100
100
 
101
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
101
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
102
102
  with(entity, check, :redis => redis).and_return(nil)
103
103
 
104
104
  aget "/status/#{entity_name_esc}/#{check}"
105
- last_response.should be_forbidden
105
+ expect(last_response).to be_forbidden
106
106
  end
107
107
 
108
108
  it "returns a list of scheduled maintenance periods for an entity" do
109
109
  sched = double('sched', :to_json => 'sched!'.to_json)
110
110
  result = {:entity => entity_name, :check => check, :scheduled_maintenances => sched}
111
- entity_presenter.should_receive(:scheduled_maintenances).with(nil, nil).and_return(result)
112
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
111
+ expect(entity_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(result)
112
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
113
113
  with(entity, :redis => redis).and_return(entity_presenter)
114
- Flapjack::Data::Entity.should_receive(:find_by_name).
114
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
115
115
  with(entity_name, :redis => redis).and_return(entity)
116
116
 
117
117
  aget "/scheduled_maintenances/#{entity_name_esc}"
118
- last_response.should be_ok
119
- last_response.body.should == [{:check => check, :scheduled_maintenance => sched}].to_json
118
+ expect(last_response).to be_ok
119
+ expect(last_response.body).to eq([{:check => check, :scheduled_maintenance => sched}].to_json)
120
120
  end
121
121
 
122
122
  it "returns a list of scheduled maintenance periods within a time window for an entity" do
@@ -125,75 +125,75 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
125
125
 
126
126
  sched = double('sched', :to_json => 'sched!'.to_json)
127
127
  result = {:entity => entity_name, :check => check, :scheduled_maintenances => sched}
128
- entity_presenter.should_receive(:scheduled_maintenances).with(start.to_i, finish.to_i).and_return(result)
129
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
128
+ expect(entity_presenter).to receive(:scheduled_maintenances).with(start.to_i, finish.to_i).and_return(result)
129
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
130
130
  with(entity, :redis => redis).and_return(entity_presenter)
131
- Flapjack::Data::Entity.should_receive(:find_by_name).
131
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
132
132
  with(entity_name, :redis => redis).and_return(entity)
133
133
 
134
134
  aget "/scheduled_maintenances/#{entity_name_esc}?" +
135
135
  "start_time=#{CGI.escape(start.iso8601)}&end_time=#{CGI.escape(finish.iso8601)}"
136
- last_response.should be_ok
137
- last_response.body.should == [{:check => check, :scheduled_maintenance => sched}].to_json
136
+ expect(last_response).to be_ok
137
+ expect(last_response.body).to eq([{:check => check, :scheduled_maintenance => sched}].to_json)
138
138
  end
139
139
 
140
140
  it "returns a list of scheduled maintenance periods for a check on an entity" do
141
141
  sched = double('sched', :to_json => 'sched!'.to_json)
142
- entity_check_presenter.should_receive(:scheduled_maintenances).with(nil, nil).and_return(sched)
143
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
142
+ expect(entity_check_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(sched)
143
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
144
144
  with(entity_check).and_return(entity_check_presenter)
145
- Flapjack::Data::Entity.should_receive(:find_by_name).
145
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
146
146
  with(entity_name, :redis => redis).and_return(entity)
147
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
147
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
148
148
  with(entity, check, :redis => redis).and_return(entity_check)
149
149
 
150
150
  aget "/scheduled_maintenances/#{entity_name_esc}/#{check}"
151
- last_response.should be_ok
152
- last_response.body.should == 'sched!'.to_json
151
+ expect(last_response).to be_ok
152
+ expect(last_response.body).to eq('sched!'.to_json)
153
153
  end
154
154
 
155
155
  it "creates an acknowledgement for an entity check" do
156
- entity_check.should_receive(:entity_name).and_return(entity_name)
157
- entity_check.should_receive(:check).and_return(check)
156
+ expect(entity_check).to receive(:entity_name).and_return(entity_name)
157
+ expect(entity_check).to receive(:check).and_return(check)
158
158
 
159
- Flapjack::Data::Entity.should_receive(:find_by_name).
159
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
160
160
  with(entity_name, :redis => redis).and_return(entity)
161
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
161
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
162
162
  with(entity, check, :redis => redis).and_return(entity_check)
163
- Flapjack::Data::Event.should_receive(:create_acknowledgement).
163
+ expect(Flapjack::Data::Event).to receive(:create_acknowledgement).
164
164
  with(entity_name, check, :summary => nil, :duration => (4 * 60 * 60), :redis => redis)
165
165
 
166
166
  apost "/acknowledgements/#{entity_name_esc}/#{check}"
167
- last_response.status.should == 204
167
+ expect(last_response.status).to eq(204)
168
168
  end
169
169
 
170
170
  it "returns a list of unscheduled maintenance periods for an entity" do
171
171
  unsched = double('unsched', :to_json => 'unsched!'.to_json)
172
172
  result = {:entity => entity_name, :check => check, :unscheduled_maintenances => unsched}
173
- entity_presenter.should_receive(:unscheduled_maintenances).with(nil, nil).and_return(result)
174
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
173
+ expect(entity_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(result)
174
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
175
175
  with(entity, :redis => redis).and_return(entity_presenter)
176
- Flapjack::Data::Entity.should_receive(:find_by_name).
176
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
177
177
  with(entity_name, :redis => redis).and_return(entity)
178
178
 
179
179
  aget "/unscheduled_maintenances/#{entity_name_esc}"
180
- last_response.should be_ok
181
- last_response.body.should == [{:check => check, :unscheduled_maintenance => unsched}].to_json
180
+ expect(last_response).to be_ok
181
+ expect(last_response.body).to eq([{:check => check, :unscheduled_maintenance => unsched}].to_json)
182
182
  end
183
183
 
184
184
  it "returns a list of unscheduled maintenance periods for a check on an entity" do
185
185
  unsched = double('unsched', :to_json => 'unsched!'.to_json)
186
- entity_check_presenter.should_receive(:unscheduled_maintenances).with(nil, nil).and_return(unsched)
187
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
186
+ expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(unsched)
187
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
188
188
  with(entity_check).and_return(entity_check_presenter)
189
- Flapjack::Data::Entity.should_receive(:find_by_name).
189
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
190
190
  with(entity_name, :redis => redis).and_return(entity)
191
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
191
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
192
192
  with(entity, check, :redis => redis).and_return(entity_check)
193
193
 
194
194
  aget "/unscheduled_maintenances/#{entity_name_esc}/#{check}"
195
- last_response.should be_ok
196
- last_response.body.should == 'unsched!'.to_json
195
+ expect(last_response).to be_ok
196
+ expect(last_response.body).to eq('unsched!'.to_json)
197
197
  end
198
198
 
199
199
  it "returns a list of unscheduled maintenance periods within a time window for a check an entity" do
@@ -201,93 +201,93 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
201
201
  finish = Time.parse('6 Jan 2012')
202
202
 
203
203
  unsched = double('unsched', :to_json => 'unsched!'.to_json)
204
- entity_check_presenter.should_receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(unsched)
205
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
204
+ expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(unsched)
205
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
206
206
  with(entity_check).and_return(entity_check_presenter)
207
- Flapjack::Data::Entity.should_receive(:find_by_name).
207
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
208
208
  with(entity_name, :redis => redis).and_return(entity)
209
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
209
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
210
210
  with(entity, check, :redis => redis).and_return(entity_check)
211
211
 
212
212
  aget "/unscheduled_maintenances/#{entity_name_esc}/#{check}" +
213
213
  "?start_time=#{CGI.escape(start.iso8601)}&end_time=#{CGI.escape(finish.iso8601)}"
214
- last_response.should be_ok
215
- last_response.body.should == 'unsched!'.to_json
214
+ expect(last_response).to be_ok
215
+ expect(last_response.body).to eq('unsched!'.to_json)
216
216
  end
217
217
 
218
218
  it "returns a list of outages for an entity" do
219
219
  out = double('out', :to_json => 'out!'.to_json)
220
220
  result = {:entity => entity_name, :check => check, :outages => out}
221
- entity_presenter.should_receive(:outages).with(nil, nil).and_return(result)
222
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
221
+ expect(entity_presenter).to receive(:outages).with(nil, nil).and_return(result)
222
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
223
223
  with(entity, :redis => redis).and_return(entity_presenter)
224
- Flapjack::Data::Entity.should_receive(:find_by_name).
224
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
225
225
  with(entity_name, :redis => redis).and_return(entity)
226
226
 
227
227
  aget "/outages/#{entity_name_esc}"
228
- last_response.should be_ok
229
- last_response.body.should == [{:check => check, :outages => out}].to_json
228
+ expect(last_response).to be_ok
229
+ expect(last_response.body).to eq([{:check => check, :outages => out}].to_json)
230
230
  end
231
231
 
232
232
  it "returns a list of outages for a check on an entity" do
233
233
  out = double('out', :to_json => 'out!'.to_json)
234
- entity_check_presenter.should_receive(:outages).with(nil, nil).and_return(out)
235
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
234
+ expect(entity_check_presenter).to receive(:outages).with(nil, nil).and_return(out)
235
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
236
236
  with(entity_check).and_return(entity_check_presenter)
237
- Flapjack::Data::Entity.should_receive(:find_by_name).
237
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
238
238
  with(entity_name, :redis => redis).and_return(entity)
239
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
239
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
240
240
  with(entity, check, :redis => redis).and_return(entity_check)
241
241
 
242
242
  aget "/outages/#{entity_name_esc}/#{check}"
243
- last_response.should be_ok
244
- last_response.body.should == 'out!'.to_json
243
+ expect(last_response).to be_ok
244
+ expect(last_response.body).to eq('out!'.to_json)
245
245
  end
246
246
 
247
247
  it "returns a list of downtimes for an entity" do
248
248
  down = double('down', :to_json => 'down!'.to_json)
249
249
  result = {:entity => entity_name, :check => check, :downtime => down}
250
- entity_presenter.should_receive(:downtime).with(nil, nil).and_return(result)
251
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
250
+ expect(entity_presenter).to receive(:downtime).with(nil, nil).and_return(result)
251
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
252
252
  with(entity, :redis => redis).and_return(entity_presenter)
253
- Flapjack::Data::Entity.should_receive(:find_by_name).
253
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
254
254
  with(entity_name, :redis => redis).and_return(entity)
255
255
 
256
256
  aget "/downtime/#{entity_name_esc}"
257
- last_response.should be_ok
258
- last_response.body.should == [{:check => check, :downtime => down}].to_json
257
+ expect(last_response).to be_ok
258
+ expect(last_response.body).to eq([{:check => check, :downtime => down}].to_json)
259
259
  end
260
260
 
261
261
  it "returns a list of downtimes for a check on an entity" do
262
262
  down = double('down', :to_json => 'down!'.to_json)
263
- entity_check_presenter.should_receive(:downtime).with(nil, nil).and_return(down)
264
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
263
+ expect(entity_check_presenter).to receive(:downtime).with(nil, nil).and_return(down)
264
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
265
265
  with(entity_check).and_return(entity_check_presenter)
266
- Flapjack::Data::Entity.should_receive(:find_by_name).
266
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
267
267
  with(entity_name, :redis => redis).and_return(entity)
268
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
268
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
269
269
  with(entity, check, :redis => redis).and_return(entity_check)
270
270
 
271
271
  aget "/downtime/#{entity_name_esc}/#{check}"
272
- last_response.should be_ok
273
- last_response.body.should == 'down!'.to_json
272
+ expect(last_response).to be_ok
273
+ expect(last_response.body).to eq('down!'.to_json)
274
274
  end
275
275
 
276
276
  it "creates a test notification event for check on an entity" do
277
- Flapjack::Data::Entity.should_receive(:find_by_name).
277
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
278
278
  with(entity_name, :redis => redis).and_return(entity)
279
- entity.should_receive(:name).and_return(entity_name)
280
- entity_check.should_receive(:entity).and_return(entity)
281
- entity_check.should_receive(:entity_name).and_return(entity_name)
282
- entity_check.should_receive(:check).and_return('foo')
283
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
279
+ expect(entity).to receive(:name).and_return(entity_name)
280
+ expect(entity_check).to receive(:entity).and_return(entity)
281
+ expect(entity_check).to receive(:entity_name).and_return(entity_name)
282
+ expect(entity_check).to receive(:check).and_return('foo')
283
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
284
284
  with(entity, 'foo', :redis => redis).and_return(entity_check)
285
285
 
286
- Flapjack::Data::Event.should_receive(:test_notifications).
286
+ expect(Flapjack::Data::Event).to receive(:test_notifications).
287
287
  with(entity_name, 'foo', hash_including(:redis => redis))
288
288
 
289
289
  apost "/test_notifications/#{entity_name_esc}/foo"
290
- last_response.status.should == 204
290
+ expect(last_response.status).to eq(204)
291
291
  end
292
292
 
293
293
  end
@@ -297,107 +297,107 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
297
297
  it "returns the status for all checks on an entity" do
298
298
  status = double('status')
299
299
  result = [{:entity => entity_name, :check => check, :status => status}]
300
- entity_presenter.should_receive(:status).and_return(result)
300
+ expect(entity_presenter).to receive(:status).and_return(result)
301
301
 
302
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
302
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
303
303
  with(entity, :redis => redis).and_return(entity_presenter)
304
304
 
305
- Flapjack::Data::Entity.should_receive(:find_by_name).
305
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
306
306
  with(entity_name, :redis => redis).and_return(entity)
307
307
 
308
308
  aget "/status", :entity => entity_name
309
- last_response.body.should == result.to_json
309
+ expect(last_response.body).to eq(result.to_json)
310
310
  end
311
311
 
312
312
  it "should not show the status for an entity that's not found" do
313
- Flapjack::Data::Entity.should_receive(:find_by_name).
313
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
314
314
  with(entity_name, :redis => redis).and_return(nil)
315
315
 
316
316
  aget "/status", :entity => entity_name
317
- last_response.should be_forbidden
317
+ expect(last_response).to be_forbidden
318
318
  end
319
319
 
320
320
  it "returns the status for a check on an entity" do
321
321
  status = double('status')
322
322
  result = [{:entity => entity_name, :check => check, :status => status}]
323
- entity_check_presenter.should_receive(:status).and_return(status)
323
+ expect(entity_check_presenter).to receive(:status).and_return(status)
324
324
 
325
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
325
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
326
326
  with(entity_check).and_return(entity_check_presenter)
327
327
 
328
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
328
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
329
329
  with(entity, check, :redis => redis).and_return(entity_check)
330
330
 
331
- Flapjack::Data::Entity.should_receive(:find_by_name).
331
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
332
332
  with(entity_name, :redis => redis).and_return(entity)
333
333
 
334
334
  aget "/status", :check => {entity_name => check}
335
- last_response.should be_ok
336
- last_response.body.should == result.to_json
335
+ expect(last_response).to be_ok
336
+ expect(last_response.body).to eq(result.to_json)
337
337
  end
338
338
 
339
339
  it "should not show the status for a check on an entity that's not found" do
340
- Flapjack::Data::Entity.should_receive(:find_by_name).
340
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
341
341
  with(entity_name, :redis => redis).and_return(nil)
342
342
 
343
343
  aget "/status", :check => {entity_name => check}
344
- last_response.should be_forbidden
344
+ expect(last_response).to be_forbidden
345
345
  end
346
346
 
347
347
  it "should not show the status for a check that's not found on an entity" do
348
- Flapjack::Data::Entity.should_receive(:find_by_name).
348
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
349
349
  with(entity_name, :redis => redis).and_return(entity)
350
350
 
351
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
351
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
352
352
  with(entity, check, :redis => redis).and_return(nil)
353
353
 
354
354
  aget "/status", :check => {entity_name => check}
355
- last_response.should be_forbidden
355
+ expect(last_response).to be_forbidden
356
356
  end
357
357
 
358
358
  it "creates an acknowledgement for an entity check" do
359
- Flapjack::Data::Entity.should_receive(:find_by_name).
359
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
360
360
  with(entity_name, :redis => redis).and_return(entity)
361
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
361
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
362
362
  with(entity, check, :redis => redis).and_return(entity_check)
363
363
 
364
- entity_check.should_receive(:entity_name).and_return(entity_name)
365
- entity_check.should_receive(:check).and_return(check)
364
+ expect(entity_check).to receive(:entity_name).and_return(entity_name)
365
+ expect(entity_check).to receive(:check).and_return(check)
366
366
 
367
- Flapjack::Data::Event.should_receive(:create_acknowledgement).
367
+ expect(Flapjack::Data::Event).to receive(:create_acknowledgement).
368
368
  with(entity_name, check, :summary => nil, :duration => (4 * 60 * 60), :redis => redis)
369
369
 
370
370
  apost '/acknowledgements',:check => {entity_name => check}
371
- last_response.status.should == 204
371
+ expect(last_response.status).to eq(204)
372
372
  end
373
373
 
374
374
  it "deletes an unscheduled maintenance period for an entity check" do
375
375
  end_time = Time.now + (60 * 60) # an hour from now
376
- entity_check.should_receive(:end_unscheduled_maintenance).with(end_time.to_i)
376
+ expect(entity_check).to receive(:end_unscheduled_maintenance).with(end_time.to_i)
377
377
 
378
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
378
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
379
379
  with(entity, check, :redis => redis).and_return(entity_check)
380
380
 
381
- Flapjack::Data::Entity.should_receive(:find_by_name).
381
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
382
382
  with(entity_name, :redis => redis).and_return(entity)
383
383
 
384
384
  adelete "/unscheduled_maintenances", :check => {entity_name => check}, :end_time => end_time.iso8601
385
- last_response.status.should == 204
385
+ expect(last_response.status).to eq(204)
386
386
  end
387
387
 
388
388
  it "creates a scheduled maintenance period for an entity check" do
389
389
  start = Time.now + (60 * 60) # an hour from now
390
390
  duration = (2 * 60 * 60) # two hours
391
- Flapjack::Data::Entity.should_receive(:find_by_name).
391
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
392
392
  with(entity_name, :redis => redis).and_return(entity)
393
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
393
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
394
394
  with(entity, check, :redis => redis).and_return(entity_check)
395
- entity_check.should_receive(:create_scheduled_maintenance).
395
+ expect(entity_check).to receive(:create_scheduled_maintenance).
396
396
  with(start.getutc.to_i, duration, :summary => 'test')
397
397
 
398
398
  apost "/scheduled_maintenances/#{entity_name_esc}/#{check}?" +
399
399
  "start_time=#{CGI.escape(start.iso8601)}&summary=test&duration=#{duration}"
400
- last_response.status.should == 204
400
+ expect(last_response.status).to eq(204)
401
401
  end
402
402
 
403
403
  it "doesn't create a scheduled maintenance period if the start time isn't passed" do
@@ -405,28 +405,28 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
405
405
 
406
406
  apost "/scheduled_maintenances/#{entity_name_esc}/#{check}?" +
407
407
  "summary=test&duration=#{duration}"
408
- last_response.status.should == 403
408
+ expect(last_response.status).to eq(403)
409
409
  end
410
410
 
411
411
  it "deletes a scheduled maintenance period for an entity check" do
412
412
  start_time = Time.now + (60 * 60) # an hour from now
413
- entity_check.should_receive(:end_scheduled_maintenance).with(start_time.to_i)
413
+ expect(entity_check).to receive(:end_scheduled_maintenance).with(start_time.to_i)
414
414
 
415
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
415
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
416
416
  with(entity, check, :redis => redis).and_return(entity_check)
417
417
 
418
- Flapjack::Data::Entity.should_receive(:find_by_name).
418
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
419
419
  with(entity_name, :redis => redis).and_return(entity)
420
420
 
421
421
  adelete "/scheduled_maintenances", :check => {entity_name => check}, :start_time => start_time.iso8601
422
- last_response.status.should == 204
422
+ expect(last_response.status).to eq(204)
423
423
  end
424
424
 
425
425
  it "doesn't delete a scheduled maintenance period if the start time isn't passed" do
426
- entity_check.should_not_receive(:end_scheduled_maintenance)
426
+ expect(entity_check).not_to receive(:end_scheduled_maintenance)
427
427
 
428
428
  adelete "/scheduled_maintenances", :check => {entity_name => check}
429
- last_response.status.should == 403
429
+ expect(last_response.status).to eq(403)
430
430
  end
431
431
 
432
432
  it "deletes scheduled maintenance periods for multiple entity checks" do
@@ -434,36 +434,36 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
434
434
 
435
435
  entity_check_2 = double(Flapjack::Data::EntityCheck)
436
436
 
437
- entity_check.should_receive(:end_scheduled_maintenance).with(start_time.to_i)
438
- entity_check_2.should_receive(:end_scheduled_maintenance).with(start_time.to_i)
437
+ expect(entity_check).to receive(:end_scheduled_maintenance).with(start_time.to_i)
438
+ expect(entity_check_2).to receive(:end_scheduled_maintenance).with(start_time.to_i)
439
439
 
440
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
440
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
441
441
  with(entity, check, :redis => redis).and_return(entity_check)
442
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
442
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
443
443
  with(entity, 'foo', :redis => redis).and_return(entity_check_2)
444
444
 
445
- Flapjack::Data::Entity.should_receive(:find_by_name).
445
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
446
446
  with(entity_name, :redis => redis).and_return(entity)
447
447
 
448
448
  adelete "/scheduled_maintenances", :check => {entity_name => [check, 'foo']}, :start_time => start_time.iso8601
449
- last_response.status.should == 204
449
+ expect(last_response.status).to eq(204)
450
450
  end
451
451
 
452
452
  it "returns a list of scheduled maintenance periods for an entity" do
453
453
  sm = double('sched_maint')
454
454
  result = [{:entity => entity_name, :check => check, :scheduled_maintenances => sm}]
455
455
 
456
- entity_presenter.should_receive(:scheduled_maintenances).with(nil, nil).and_return(result)
456
+ expect(entity_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(result)
457
457
 
458
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
458
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
459
459
  with(entity, :redis => redis).and_return(entity_presenter)
460
460
 
461
- Flapjack::Data::Entity.should_receive(:find_by_name).
461
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
462
462
  with(entity_name, :redis => redis).and_return(entity)
463
463
 
464
464
  aget "/scheduled_maintenances", :entity => entity_name
465
- last_response.should be_ok
466
- last_response.body.should == result.to_json
465
+ expect(last_response).to be_ok
466
+ expect(last_response.body).to eq(result.to_json)
467
467
  end
468
468
 
469
469
  it "returns a list of scheduled maintenance periods within a time window for an entity" do
@@ -473,75 +473,75 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
473
473
  sm = double('sched_maint')
474
474
  result = [{:entity => entity_name, :check => check, :scheduled_maintenances => sm}]
475
475
 
476
- entity_presenter.should_receive(:scheduled_maintenances).with(start.to_i, finish.to_i).and_return(result)
476
+ expect(entity_presenter).to receive(:scheduled_maintenances).with(start.to_i, finish.to_i).and_return(result)
477
477
 
478
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
478
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
479
479
  with(entity, :redis => redis).and_return(entity_presenter)
480
480
 
481
- Flapjack::Data::Entity.should_receive(:find_by_name).
481
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
482
482
  with(entity_name, :redis => redis).and_return(entity)
483
483
 
484
484
  aget "/scheduled_maintenances", :entity => entity_name,
485
485
  :start_time => start.iso8601, :end_time => finish.iso8601
486
- last_response.should be_ok
487
- last_response.body.should == result.to_json
486
+ expect(last_response).to be_ok
487
+ expect(last_response.body).to eq(result.to_json)
488
488
  end
489
489
 
490
490
  it "returns a list of scheduled maintenance periods for a check on an entity" do
491
491
  sm = double('sched_maint')
492
492
  result = [{:entity => entity_name, :check => check, :scheduled_maintenances => sm}]
493
493
 
494
- entity_check_presenter.should_receive(:scheduled_maintenances).with(nil, nil).and_return(sm)
494
+ expect(entity_check_presenter).to receive(:scheduled_maintenances).with(nil, nil).and_return(sm)
495
495
 
496
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
496
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
497
497
  with(entity_check).and_return(entity_check_presenter)
498
498
 
499
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
499
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
500
500
  with(entity, check, :redis => redis).and_return(entity_check)
501
501
 
502
- Flapjack::Data::Entity.should_receive(:find_by_name).
502
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
503
503
  with(entity_name, :redis => redis).and_return(entity)
504
504
 
505
505
  aget "/scheduled_maintenances", :check => {entity_name => check}
506
- last_response.should be_ok
507
- last_response.body.should == result.to_json
506
+ expect(last_response).to be_ok
507
+ expect(last_response.body).to eq(result.to_json)
508
508
  end
509
509
 
510
510
  it "returns a list of unscheduled maintenance periods for an entity" do
511
511
  um = double('unsched_maint')
512
512
  result = [{:entity => entity_name, :check => check, :unscheduled_maintenances => um}]
513
513
 
514
- entity_presenter.should_receive(:unscheduled_maintenances).with(nil, nil).and_return(result)
514
+ expect(entity_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(result)
515
515
 
516
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
516
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
517
517
  with(entity, :redis => redis).and_return(entity_presenter)
518
518
 
519
- Flapjack::Data::Entity.should_receive(:find_by_name).
519
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
520
520
  with(entity_name, :redis => redis).and_return(entity)
521
521
 
522
522
  aget "/unscheduled_maintenances", :entity => entity_name
523
- last_response.should be_ok
524
- last_response.body.should == result.to_json
523
+ expect(last_response).to be_ok
524
+ expect(last_response.body).to eq(result.to_json)
525
525
  end
526
526
 
527
527
  it "returns a list of unscheduled maintenance periods for a check on an entity" do
528
528
  um = double('unsched_maint')
529
529
  result = [{:entity => entity_name, :check => check, :unscheduled_maintenances => um}]
530
530
 
531
- entity_check_presenter.should_receive(:unscheduled_maintenances).with(nil, nil).and_return(um)
531
+ expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(nil, nil).and_return(um)
532
532
 
533
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
533
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
534
534
  with(entity_check).and_return(entity_check_presenter)
535
535
 
536
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
536
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
537
537
  with(entity, check, :redis => redis).and_return(entity_check)
538
538
 
539
- Flapjack::Data::Entity.should_receive(:find_by_name).
539
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
540
540
  with(entity_name, :redis => redis).and_return(entity)
541
541
 
542
542
  aget "/unscheduled_maintenances", :check => {entity_name => check}
543
- last_response.should be_ok
544
- last_response.body.should == result.to_json
543
+ expect(last_response).to be_ok
544
+ expect(last_response.body).to eq(result.to_json)
545
545
  end
546
546
 
547
547
  it "returns a list of unscheduled maintenance periods within a time window for a check an entity" do
@@ -551,21 +551,21 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
551
551
  um = double('unsched_maint')
552
552
  result = [{:entity => entity_name, :check => check, :unscheduled_maintenances => um}]
553
553
 
554
- entity_check_presenter.should_receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(um)
554
+ expect(entity_check_presenter).to receive(:unscheduled_maintenances).with(start.to_i, finish.to_i).and_return(um)
555
555
 
556
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
556
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
557
557
  with(entity_check).and_return(entity_check_presenter)
558
558
 
559
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
559
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
560
560
  with(entity, check, :redis => redis).and_return(entity_check)
561
561
 
562
- Flapjack::Data::Entity.should_receive(:find_by_name).
562
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
563
563
  with(entity_name, :redis => redis).and_return(entity)
564
564
 
565
565
  aget "/unscheduled_maintenances", :check => {entity_name => check},
566
566
  :start_time => start.iso8601, :end_time => finish.iso8601
567
- last_response.should be_ok
568
- last_response.body.should == result.to_json
567
+ expect(last_response).to be_ok
568
+ expect(last_response.body).to eq(result.to_json)
569
569
  end
570
570
 
571
571
  it "returns a list of outages, for one whole entity and two checks on another entity" do
@@ -586,136 +586,136 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
586
586
  foo_check_presenter = double(Flapjack::Gateways::API::EntityCheckPresenter)
587
587
  bar_check_presenter = double(Flapjack::Gateways::API::EntityCheckPresenter)
588
588
 
589
- entity_presenter.should_receive(:outages).with(nil, nil).and_return(result[0])
590
- foo_check_presenter.should_receive(:outages).with(nil, nil).and_return(outages_2)
591
- bar_check_presenter.should_receive(:outages).with(nil, nil).and_return(outages_3)
589
+ expect(entity_presenter).to receive(:outages).with(nil, nil).and_return(result[0])
590
+ expect(foo_check_presenter).to receive(:outages).with(nil, nil).and_return(outages_2)
591
+ expect(bar_check_presenter).to receive(:outages).with(nil, nil).and_return(outages_3)
592
592
 
593
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
593
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
594
594
  with(entity, :redis => redis).and_return(entity_presenter)
595
595
 
596
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
596
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
597
597
  with(foo_check).and_return(foo_check_presenter)
598
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
598
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
599
599
  with(bar_check).and_return(bar_check_presenter)
600
600
 
601
- Flapjack::Data::Entity.should_receive(:find_by_name).
601
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
602
602
  with(entity_name, :redis => redis).and_return(entity)
603
- Flapjack::Data::Entity.should_receive(:find_by_name).
603
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
604
604
  with(entity_2_name, :redis => redis).and_return(entity_2)
605
605
 
606
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
606
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
607
607
  with(entity_2, 'foo', :redis => redis).and_return(foo_check)
608
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
608
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
609
609
  with(entity_2, 'bar', :redis => redis).and_return(bar_check)
610
610
 
611
611
  aget "/outages", :entity => entity_name, :check => {entity_2_name => ['foo', 'bar']}
612
- last_response.should be_ok
613
- last_response.body.should == result.to_json
612
+ expect(last_response).to be_ok
613
+ expect(last_response.body).to eq(result.to_json)
614
614
  end
615
615
 
616
616
  it "returns a list of outages for a check on an entity" do
617
617
  outages = double('outages')
618
618
  result = [{:entity => entity_name, :check => check, :outages => outages}]
619
619
 
620
- entity_check_presenter.should_receive(:outages).with(nil, nil).and_return(outages)
620
+ expect(entity_check_presenter).to receive(:outages).with(nil, nil).and_return(outages)
621
621
 
622
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
622
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
623
623
  with(entity_check).and_return(entity_check_presenter)
624
624
 
625
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
625
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
626
626
  with(entity, check, :redis => redis).and_return(entity_check)
627
627
 
628
- Flapjack::Data::Entity.should_receive(:find_by_name).
628
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
629
629
  with(entity_name, :redis => redis).and_return(entity)
630
630
 
631
631
  aget "/outages", :check => {entity_name => check}
632
- last_response.should be_ok
633
- last_response.body.should == result.to_json
632
+ expect(last_response).to be_ok
633
+ expect(last_response.body).to eq(result.to_json)
634
634
  end
635
635
 
636
636
  it "returns a list of downtimes for an entity" do
637
637
  downtime = double('downtime')
638
638
  result = [{:entity => entity_name, :check => check, :downtime => downtime}]
639
639
 
640
- entity_presenter.should_receive(:downtime).with(nil, nil).and_return(result)
640
+ expect(entity_presenter).to receive(:downtime).with(nil, nil).and_return(result)
641
641
 
642
- Flapjack::Gateways::API::EntityPresenter.should_receive(:new).
642
+ expect(Flapjack::Gateways::API::EntityPresenter).to receive(:new).
643
643
  with(entity, :redis => redis).and_return(entity_presenter)
644
644
 
645
- Flapjack::Data::Entity.should_receive(:find_by_name).
645
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
646
646
  with(entity_name, :redis => redis).and_return(entity)
647
647
 
648
648
  aget "/downtime", :entity => entity_name
649
- last_response.should be_ok
650
- last_response.body.should == result.to_json
649
+ expect(last_response).to be_ok
650
+ expect(last_response.body).to eq(result.to_json)
651
651
  end
652
652
 
653
653
  it "returns a list of downtimes for a check on an entity" do
654
654
  downtime = double('downtime')
655
655
  result = [{:entity => entity_name, :check => check, :downtime => downtime}]
656
656
 
657
- entity_check_presenter.should_receive(:downtime).with(nil, nil).and_return(downtime)
657
+ expect(entity_check_presenter).to receive(:downtime).with(nil, nil).and_return(downtime)
658
658
 
659
- Flapjack::Gateways::API::EntityCheckPresenter.should_receive(:new).
659
+ expect(Flapjack::Gateways::API::EntityCheckPresenter).to receive(:new).
660
660
  with(entity_check).and_return(entity_check_presenter)
661
661
 
662
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
662
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
663
663
  with(entity, check, :redis => redis).and_return(entity_check)
664
664
 
665
- Flapjack::Data::Entity.should_receive(:find_by_name).
665
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
666
666
  with(entity_name, :redis => redis).and_return(entity)
667
667
 
668
668
  aget "/downtime", :check => {entity_name => check}
669
- last_response.should be_ok
670
- last_response.body.should == result.to_json
669
+ expect(last_response).to be_ok
670
+ expect(last_response.body).to eq(result.to_json)
671
671
  end
672
672
 
673
673
  it "creates test notification events for all checks on an entity" do
674
- entity.should_receive(:check_list).and_return([check, 'foo'])
675
- entity.should_receive(:name).twice.and_return(entity_name)
676
- Flapjack::Data::Entity.should_receive(:find_by_name).
674
+ expect(entity).to receive(:check_list).and_return([check, 'foo'])
675
+ expect(entity).to receive(:name).twice.and_return(entity_name)
676
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
677
677
  with(entity_name, :redis => redis).and_return(entity)
678
678
 
679
- entity_check.should_receive(:entity).and_return(entity)
680
- entity_check.should_receive(:entity_name).and_return(entity_name)
681
- entity_check.should_receive(:check).and_return(check)
679
+ expect(entity_check).to receive(:entity).and_return(entity)
680
+ expect(entity_check).to receive(:entity_name).and_return(entity_name)
681
+ expect(entity_check).to receive(:check).and_return(check)
682
682
 
683
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
683
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
684
684
  with(entity, check, :redis => redis).and_return(entity_check)
685
685
 
686
686
  entity_check_2 = double(Flapjack::Data::EntityCheck)
687
- entity_check_2.should_receive(:entity).and_return(entity)
688
- entity_check_2.should_receive(:entity_name).and_return(entity_name)
689
- entity_check_2.should_receive(:check).and_return('foo')
687
+ expect(entity_check_2).to receive(:entity).and_return(entity)
688
+ expect(entity_check_2).to receive(:entity_name).and_return(entity_name)
689
+ expect(entity_check_2).to receive(:check).and_return('foo')
690
690
 
691
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
691
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
692
692
  with(entity, 'foo', :redis => redis).and_return(entity_check_2)
693
693
 
694
- Flapjack::Data::Event.should_receive(:test_notifications).
694
+ expect(Flapjack::Data::Event).to receive(:test_notifications).
695
695
  with(entity_name, check, hash_including(:redis => redis))
696
696
 
697
- Flapjack::Data::Event.should_receive(:test_notifications).
697
+ expect(Flapjack::Data::Event).to receive(:test_notifications).
698
698
  with(entity_name, 'foo', hash_including(:redis => redis))
699
699
 
700
700
  apost '/test_notifications', :entity => entity_name
701
- last_response.status.should == 204
701
+ expect(last_response.status).to eq(204)
702
702
  end
703
703
 
704
704
  it "creates a test notification event for check on an entity" do
705
- Flapjack::Data::Entity.should_receive(:find_by_name).
705
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
706
706
  with(entity_name, :redis => redis).and_return(entity)
707
- entity.should_receive(:name).and_return(entity_name)
708
- entity_check.should_receive(:entity).and_return(entity)
709
- entity_check.should_receive(:entity_name).and_return(entity_name)
710
- entity_check.should_receive(:check).and_return(check)
711
- Flapjack::Data::EntityCheck.should_receive(:for_entity).
707
+ expect(entity).to receive(:name).and_return(entity_name)
708
+ expect(entity_check).to receive(:entity).and_return(entity)
709
+ expect(entity_check).to receive(:entity_name).and_return(entity_name)
710
+ expect(entity_check).to receive(:check).and_return(check)
711
+ expect(Flapjack::Data::EntityCheck).to receive(:for_entity).
712
712
  with(entity, check, :redis => redis).and_return(entity_check)
713
713
 
714
- Flapjack::Data::Event.should_receive(:test_notifications).
714
+ expect(Flapjack::Data::Event).to receive(:test_notifications).
715
715
  with(entity_name, check, hash_including(:redis => redis))
716
716
 
717
717
  apost '/test_notifications', :check => {entity_name => check}
718
- last_response.status.should == 204
718
+ expect(last_response.status).to eq(204)
719
719
  end
720
720
 
721
721
  it "creates entities from a submitted list" do
@@ -731,18 +731,18 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
731
731
  }
732
732
  ]
733
733
  }
734
- Flapjack::Data::Entity.should_receive(:add).twice
734
+ expect(Flapjack::Data::Entity).to receive(:add).twice
735
735
 
736
736
  apost "/entities", entities.to_json, {'CONTENT_TYPE' => 'application/json'}
737
- last_response.status.should == 204
737
+ expect(last_response.status).to eq(204)
738
738
  end
739
739
 
740
740
  it "does not create entities if the data is improperly formatted" do
741
- Flapjack::Data::Entity.should_not_receive(:add)
741
+ expect(Flapjack::Data::Entity).not_to receive(:add)
742
742
 
743
743
  apost "/entities", {'entities' => ["Hello", "there"]}.to_json,
744
744
  {'CONTENT_TYPE' => 'application/json'}
745
- last_response.status.should == 403
745
+ expect(last_response.status).to eq(403)
746
746
  end
747
747
 
748
748
  it "does not create entities if they don't contain an id" do
@@ -757,10 +757,10 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
757
757
  }
758
758
  ]
759
759
  }
760
- Flapjack::Data::Entity.should_receive(:add)
760
+ expect(Flapjack::Data::Entity).to receive(:add)
761
761
 
762
762
  apost "/entities", entities.to_json, {'CONTENT_TYPE' => 'application/json'}
763
- last_response.status.should == 403
763
+ expect(last_response.status).to eq(403)
764
764
  end
765
765
 
766
766
  end
@@ -768,94 +768,94 @@ describe 'Flapjack::Gateways::API::EntityMethods', :sinatra => true, :logger =>
768
768
  context "tags" do
769
769
 
770
770
  it "sets a single tag on an entity and returns current tags" do
771
- entity.should_receive(:add_tags).with('web')
772
- entity.should_receive(:tags).and_return(['web'])
773
- Flapjack::Data::Entity.should_receive(:find_by_name).
771
+ expect(entity).to receive(:add_tags).with('web')
772
+ expect(entity).to receive(:tags).and_return(['web'])
773
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
774
774
  with(entity_name, :redis => redis).and_return(entity)
775
775
 
776
776
  apost "entities/#{entity_name}/tags", :tag => 'web'
777
- last_response.should be_ok
778
- last_response.body.should be_json_eql( ['web'].to_json )
777
+ expect(last_response).to be_ok
778
+ expect(last_response.body).to eq(['web'].to_json)
779
779
  end
780
780
 
781
781
  it "does not set a single tag on an entity that's not found" do
782
- Flapjack::Data::Entity.should_receive(:find_by_name).
782
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
783
783
  with(entity_name, :redis => redis).and_return(nil)
784
784
 
785
785
  apost "entities/#{entity_name}/tags", :tag => 'web'
786
- last_response.should be_forbidden
786
+ expect(last_response).to be_forbidden
787
787
  end
788
788
 
789
789
  it "sets multiple tags on an entity and returns current tags" do
790
- entity.should_receive(:add_tags).with('web', 'app')
791
- entity.should_receive(:tags).and_return(['web', 'app'])
792
- Flapjack::Data::Entity.should_receive(:find_by_name).
790
+ expect(entity).to receive(:add_tags).with('web', 'app')
791
+ expect(entity).to receive(:tags).and_return(['web', 'app'])
792
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
793
793
  with(entity_name, :redis => redis).and_return(entity)
794
794
 
795
795
  # NB submitted at a lower level as tag[]=web&tag[]=app
796
796
  apost "entities/#{entity_name}/tags", :tag => ['web', 'app']
797
- last_response.should be_ok
798
- last_response.body.should be_json_eql( ['web', 'app'].to_json )
797
+ expect(last_response).to be_ok
798
+ expect(last_response.body).to eq(['web', 'app'].to_json)
799
799
  end
800
800
 
801
801
  it "does not set multiple tags on an entity that's not found" do
802
- Flapjack::Data::Entity.should_receive(:find_by_name).
802
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
803
803
  with(entity_name, :redis => redis).and_return(nil)
804
804
 
805
805
  apost "entities/#{entity_name}/tags", :tag => ['web', 'app']
806
- last_response.should be_forbidden
806
+ expect(last_response).to be_forbidden
807
807
  end
808
808
 
809
809
  it "removes a single tag from an entity" do
810
- entity.should_receive(:delete_tags).with('web')
811
- Flapjack::Data::Entity.should_receive(:find_by_name).
810
+ expect(entity).to receive(:delete_tags).with('web')
811
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
812
812
  with(entity_name, :redis => redis).and_return(entity)
813
813
 
814
814
  adelete "entities/#{entity_name}/tags", :tag => 'web'
815
- last_response.status.should == 204
815
+ expect(last_response.status).to eq(204)
816
816
  end
817
817
 
818
818
  it "does not remove a single tag from an entity that's not found" do
819
- Flapjack::Data::Entity.should_receive(:find_by_name).
819
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
820
820
  with(entity_name, :redis => redis).and_return(nil)
821
821
 
822
822
  adelete "entities/#{entity_name}/tags", :tag => 'web'
823
- last_response.should be_forbidden
823
+ expect(last_response).to be_forbidden
824
824
  end
825
825
 
826
826
  it "removes multiple tags from an entity" do
827
- entity.should_receive(:delete_tags).with('web', 'app')
828
- Flapjack::Data::Entity.should_receive(:find_by_name).
827
+ expect(entity).to receive(:delete_tags).with('web', 'app')
828
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
829
829
  with(entity_name, :redis => redis).and_return(entity)
830
830
 
831
831
  adelete "entities/#{entity_name}/tags", :tag => ['web', 'app']
832
- last_response.status.should == 204
832
+ expect(last_response.status).to eq(204)
833
833
  end
834
834
 
835
835
  it "does not remove multiple tags from an entity that's not found" do
836
- Flapjack::Data::Entity.should_receive(:find_by_name).
836
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
837
837
  with(entity_name, :redis => redis).and_return(nil)
838
838
 
839
839
  adelete "entities/#{entity_name}/tags", :tag => ['web', 'app']
840
- last_response.should be_forbidden
840
+ expect(last_response).to be_forbidden
841
841
  end
842
842
 
843
843
  it "gets all tags on an entity" do
844
- entity.should_receive(:tags).and_return(['web', 'app'])
845
- Flapjack::Data::Entity.should_receive(:find_by_name).
844
+ expect(entity).to receive(:tags).and_return(['web', 'app'])
845
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
846
846
  with(entity_name, :redis => redis).and_return(entity)
847
847
 
848
848
  aget "entities/#{entity_name}/tags"
849
- last_response.should be_ok
850
- last_response.body.should be_json_eql( ['web', 'app'].to_json )
849
+ expect(last_response).to be_ok
850
+ expect(last_response.body).to eq(['web', 'app'].to_json)
851
851
  end
852
852
 
853
853
  it "does not get all tags on an entity that's not found" do
854
- Flapjack::Data::Entity.should_receive(:find_by_name).
854
+ expect(Flapjack::Data::Entity).to receive(:find_by_name).
855
855
  with(entity_name, :redis => redis).and_return(nil)
856
856
 
857
857
  aget "entities/#{entity_name}/tags"
858
- last_response.should be_forbidden
858
+ expect(last_response).to be_forbidden
859
859
  end
860
860
 
861
861
  end