@@ -16,24 +16,7 @@ private class InstanceTest < Raven::Instance
16
16
end
17
17
end
18
18
19
- private class LoggerTest < Raven ::Logger
20
- getter infos = [] of String
21
-
22
- def info (message, * args)
23
- super .tap do
24
- @infos << message
25
- end
26
- end
27
- end
28
-
29
- def build_configuration
30
- Raven ::Configuration .new.tap do |config |
31
- config.dsn
= " dummy://12345:[email protected] :3000/sentry/42"
32
- config.logger = LoggerTest .new(nil )
33
- end
34
- end
35
-
36
- def with_instance (context = nil )
19
+ private def with_instance (context = nil )
37
20
yield InstanceTest .new(context, build_configuration)
38
21
end
39
22
@@ -214,17 +197,21 @@ describe Raven::Instance do
214
197
with_instance do |instance |
215
198
instance.configuration.silence_ready = false
216
199
217
- instance.report_status
218
- instance.logger.as(LoggerTest ).infos.should contain(ready_message)
200
+ Log .capture do |logs |
201
+ instance.report_status
202
+ logs.check(:info , ready_message)
203
+ end
219
204
end
220
205
end
221
206
222
207
it " logs nothing if 'silence_ready' option is true" do
223
208
with_instance do |instance |
224
209
instance.configuration.silence_ready = true
225
210
226
- instance.report_status
227
- instance.logger.as(LoggerTest ).infos.should_not contain(ready_message)
211
+ Log .capture do |logs |
212
+ instance.report_status
213
+ logs.empty
214
+ end
228
215
end
229
216
end
230
217
@@ -233,8 +220,10 @@ describe Raven::Instance do
233
220
instance.configuration.silence_ready = false
234
221
instance.configuration.dsn = " dummy://foo"
235
222
236
- instance.report_status
237
- instance.logger.as(LoggerTest ).infos.first.should contain(not_ready_message)
223
+ Log .capture do |logs |
224
+ instance.report_status
225
+ logs.check(:info , /#{ not_ready_message } / )
226
+ end
238
227
end
239
228
end
240
229
@@ -243,10 +232,12 @@ describe Raven::Instance do
243
232
instance.configuration.silence_ready = false
244
233
instance.configuration.environments = %w(production)
245
234
246
- instance.report_status
247
- instance.logger.as(LoggerTest ).infos.should contain(
248
- " #{ not_ready_message } : Not configured to send/capture in environment 'default'"
249
- )
235
+ Log .capture do |logs |
236
+ instance.report_status
237
+ logs.check(:info ,
238
+ " #{ not_ready_message } : Not configured to send/capture in environment 'default'"
239
+ )
240
+ end
250
241
end
251
242
end
252
243
end
@@ -255,7 +246,9 @@ describe Raven::Instance do
255
246
it " sends the result of Event.capture" do
256
247
with_instance do |instance |
257
248
event = instance.capture(" Test message" )
258
- instance.last_sent_event.try(& .id).should eq(event.as?(Raven ::Event ).try(& .id))
249
+
250
+ last_sent_event = instance.last_sent_event.should_not be_nil
251
+ last_sent_event.id.should eq(event.as(Raven ::Event ).id)
259
252
end
260
253
end
261
254
end
0 commit comments