@@ -171,6 +171,10 @@ def many(*args, &block) nil; end
171
171
172
172
context '#async' do
173
173
174
+ before ( :each ) do
175
+ subject . executor = ImmediateExecutor . new
176
+ end
177
+
174
178
it 'raises an error when calling a method that does not exist' do
175
179
expect {
176
180
subject . async . bogus
@@ -190,7 +194,8 @@ def many(*args, &block) nil; end
190
194
end
191
195
192
196
it 'returns a :pending IVar' do
193
- val = subject . async . wait ( 5 )
197
+ subject . executor = executor
198
+ val = subject . async . wait ( 1 )
194
199
expect ( val ) . to be_a Concurrent ::IVar
195
200
expect ( val ) . to be_pending
196
201
end
@@ -212,30 +217,25 @@ def many(*args, &block) nil; end
212
217
it 'sets the reason on failure' do
213
218
ex = ArgumentError . new
214
219
val = subject . async . boom ( ex )
215
- sleep ( 0.1 )
216
220
expect ( val . reason ) . to eq ex
217
221
expect ( val ) . to be_rejected
218
222
end
219
223
220
224
it 'sets the reason when giving too many optional arguments' do
221
225
val = subject . async . gather ( 1 , 2 , 3 , 4 , 5 )
222
- sleep ( 0.1 )
223
226
expect ( val . reason ) . to be_a StandardError
224
227
expect ( val ) . to be_rejected
225
228
end
226
229
227
230
it 'supports attribute accessors' do
228
231
subject . async . accessor = :foo
229
- sleep ( 0.1 )
230
232
val = subject . async . accessor
231
- sleep ( 0.1 )
232
233
expect ( val . value ) . to eq :foo
233
234
expect ( subject . accessor ) . to eq :foo
234
235
end
235
236
236
237
it 'supports methods with blocks' do
237
238
val = subject . async . with_block { :foo }
238
- sleep ( 0.1 )
239
239
expect ( val . value ) . to eq :foo
240
240
end
241
241
@@ -244,7 +244,6 @@ def many(*args, &block) nil; end
244
244
it 'defines the method after the first call' do
245
245
expect { subject . async . method ( :echo ) } . to raise_error ( NameError )
246
246
subject . async . echo ( :foo )
247
- sleep ( 0.1 )
248
247
expect { subject . async . method ( :echo ) } . not_to raise_error
249
248
end
250
249
0 commit comments