@@ -34,18 +34,18 @@ def dereferenceable_observable(opts = {})
34
34
end
35
35
36
36
def execute_dereferenceable ( subject )
37
- subject . post { |value | 10 }
37
+ subject . post { |value | 10 }
38
38
sleep ( 0.1 )
39
39
end
40
40
41
41
it_should_behave_like :dereferenceable
42
42
43
43
# observable
44
-
45
- subject { Agent . new ( 0 ) }
46
-
44
+
45
+ subject { Agent . new ( 0 ) }
46
+
47
47
def trigger_observable ( observable )
48
- observable . post { nil }
48
+ observable . post { nil }
49
49
sleep ( 0.1 )
50
50
end
51
51
@@ -71,25 +71,25 @@ def trigger_observable(observable)
71
71
it 'uses the executor given with the :executor option' do
72
72
executor . should_receive ( :post ) . with ( any_args ) . and_return ( 0 )
73
73
agent = Agent . new ( 0 , executor : executor )
74
- agent . post { |value | 0 }
74
+ agent . post { |value | 0 }
75
75
end
76
76
77
77
it 'uses the global operation pool when :operation is true' do
78
78
Concurrent . configuration . should_receive ( :global_operation_pool ) . and_return ( executor )
79
79
agent = Agent . new ( 0 , operation : true )
80
- agent . post { |value | 0 }
80
+ agent . post { |value | 0 }
81
81
end
82
82
83
83
it 'uses the global task pool when :task is true' do
84
84
Concurrent . configuration . should_receive ( :global_task_pool ) . and_return ( executor )
85
85
agent = Agent . new ( 0 , task : true )
86
- agent . post { |value | 0 }
86
+ agent . post { |value | 0 }
87
87
end
88
88
89
89
it 'uses the global task pool by default' do
90
90
Concurrent . configuration . should_receive ( :global_task_pool ) . and_return ( executor )
91
91
agent = Agent . new ( 0 )
92
- agent . post { |value | 0 }
92
+ agent . post { |value | 0 }
93
93
end
94
94
end
95
95
@@ -245,85 +245,85 @@ def trigger_observable(observable)
245
245
it 'calls the first exception block with a matching class' do
246
246
@expected = nil
247
247
subject .
248
- rescue ( StandardError ) { |ex | @expected = 1 } .
249
- rescue ( StandardError ) { |ex | @expected = 2 } .
250
- rescue ( StandardError ) { |ex | @expected = 3 }
251
- subject . post { raise StandardError }
252
- sleep ( 0.1 )
253
- @expected . should eq 1
254
- end
248
+ rescue ( StandardError ) { |ex | @expected = 1 } .
249
+ rescue ( StandardError ) { |ex | @expected = 2 } .
250
+ rescue ( StandardError ) { |ex | @expected = 3 }
251
+ subject . post { raise StandardError }
252
+ sleep ( 0.1 )
253
+ @expected . should eq 1
254
+ end
255
255
256
256
it 'matches all with a rescue with no class given' do
257
257
@expected = nil
258
258
subject .
259
- rescue ( LoadError ) { |ex | @expected = 1 } .
260
- rescue { |ex | @expected = 2 } .
261
- rescue ( StandardError ) { |ex | @expected = 3 }
262
- subject . post { raise NoMethodError }
263
- sleep ( 0.1 )
264
- @expected . should eq 2
265
- end
259
+ rescue ( LoadError ) { |ex | @expected = 1 } .
260
+ rescue { |ex | @expected = 2 } .
261
+ rescue ( StandardError ) { |ex | @expected = 3 }
262
+ subject . post { raise NoMethodError }
263
+ sleep ( 0.1 )
264
+ @expected . should eq 2
265
+ end
266
266
267
267
it 'searches associated rescue handlers in order' do
268
268
@expected = nil
269
269
subject .
270
- rescue ( ArgumentError ) { |ex | @expected = 1 } .
271
- rescue ( LoadError ) { |ex | @expected = 2 } .
272
- rescue ( StandardError ) { |ex | @expected = 3 }
273
- subject . post { raise ArgumentError }
274
- sleep ( 0.1 )
275
- @expected . should eq 1
270
+ rescue ( ArgumentError ) { |ex | @expected = 1 } .
271
+ rescue ( LoadError ) { |ex | @expected = 2 } .
272
+ rescue ( StandardError ) { |ex | @expected = 3 }
273
+ subject . post { raise ArgumentError }
274
+ sleep ( 0.1 )
275
+ @expected . should eq 1
276
276
277
- @expected = nil
278
- subject .
279
- rescue ( ArgumentError ) { |ex | @expected = 1 } .
280
- rescue ( LoadError ) { |ex | @expected = 2 } .
281
- rescue ( StandardError ) { |ex | @expected = 3 }
282
- subject . post { raise LoadError }
283
- sleep ( 0.1 )
284
- @expected . should eq 2
285
-
286
- @expected = nil
287
- subject .
288
- rescue ( ArgumentError ) { |ex | @expected = 1 } .
277
+ @expected = nil
278
+ subject .
279
+ rescue ( ArgumentError ) { |ex | @expected = 1 } .
289
280
rescue ( LoadError ) { |ex | @expected = 2 } .
290
281
rescue ( StandardError ) { |ex | @expected = 3 }
291
- subject . post { raise StandardError }
292
- sleep ( 0.1 )
293
- @expected . should eq 3
294
- end
282
+ subject . post { raise LoadError }
283
+ sleep ( 0.1 )
284
+ @expected . should eq 2
285
+
286
+ @expected = nil
287
+ subject .
288
+ rescue ( ArgumentError ) { |ex | @expected = 1 } .
289
+ rescue ( LoadError ) { |ex | @expected = 2 } .
290
+ rescue ( StandardError ) { |ex | @expected = 3 }
291
+ subject . post { raise StandardError }
292
+ sleep ( 0.1 )
293
+ @expected . should eq 3
294
+ end
295
295
296
296
it 'passes the exception object to the matched block' do
297
297
@expected = nil
298
298
subject .
299
- rescue ( ArgumentError ) { |ex | @expected = ex } .
300
- rescue ( LoadError ) { |ex | @expected = ex } .
301
- rescue ( StandardError ) { |ex | @expected = ex }
302
- subject . post { raise StandardError }
303
- sleep ( 0.1 )
304
- @expected . should be_a ( StandardError )
305
- end
299
+ rescue ( ArgumentError ) { |ex | @expected = ex } .
300
+ rescue ( LoadError ) { |ex | @expected = ex } .
301
+ rescue ( StandardError ) { |ex | @expected = ex }
302
+ subject . post { raise StandardError }
303
+ sleep ( 0.1 )
304
+ @expected . should be_a ( StandardError )
305
+ end
306
306
307
307
it 'ignores rescuers without a block' do
308
308
@expected = nil
309
309
subject .
310
- rescue ( StandardError ) .
311
- rescue ( StandardError ) { |ex | @expected = ex }
312
- subject . post { raise StandardError }
313
- sleep ( 0.1 )
314
- @expected . should be_a ( StandardError )
315
- end
310
+ rescue ( StandardError ) .
311
+ rescue ( StandardError ) { |ex | @expected = ex }
312
+ subject . post { raise StandardError }
313
+ sleep ( 0.1 )
314
+ @expected . should be_a ( StandardError )
315
+ end
316
316
317
317
it 'supresses the exception if no rescue matches' do
318
318
lambda {
319
319
subject .
320
- rescue ( ArgumentError ) { |ex | @expected = ex } .
321
- rescue ( NotImplementedError ) { |ex | @expected = ex } .
322
- rescue ( NoMethodError ) { |ex | @expected = ex }
320
+ rescue ( ArgumentError ) { |ex | @expected = ex } .
321
+ rescue ( NotImplementedError ) { |ex | @expected = ex } .
322
+ rescue ( NoMethodError ) { |ex | @expected = ex }
323
323
subject . post { raise StandardError }
324
324
sleep ( 0.1 )
325
325
} . should_not raise_error
326
- end
326
+ end
327
327
328
328
it 'suppresses exceptions thrown from rescue handlers' do
329
329
lambda {
0 commit comments