@@ -171,6 +171,10 @@ def many(*args, &block) nil; end
171171
172172 context '#async' do
173173
174+ before ( :each ) do
175+ subject . executor = ImmediateExecutor . new
176+ end
177+
174178 it 'raises an error when calling a method that does not exist' do
175179 expect {
176180 subject . async . bogus
@@ -190,7 +194,8 @@ def many(*args, &block) nil; end
190194 end
191195
192196 it 'returns a :pending IVar' do
193- val = subject . async . wait ( 5 )
197+ subject . executor = executor
198+ val = subject . async . wait ( 1 )
194199 expect ( val ) . to be_a Concurrent ::IVar
195200 expect ( val ) . to be_pending
196201 end
@@ -212,30 +217,25 @@ def many(*args, &block) nil; end
212217 it 'sets the reason on failure' do
213218 ex = ArgumentError . new
214219 val = subject . async . boom ( ex )
215- sleep ( 0.1 )
216220 expect ( val . reason ) . to eq ex
217221 expect ( val ) . to be_rejected
218222 end
219223
220224 it 'sets the reason when giving too many optional arguments' do
221225 val = subject . async . gather ( 1 , 2 , 3 , 4 , 5 )
222- sleep ( 0.1 )
223226 expect ( val . reason ) . to be_a StandardError
224227 expect ( val ) . to be_rejected
225228 end
226229
227230 it 'supports attribute accessors' do
228231 subject . async . accessor = :foo
229- sleep ( 0.1 )
230232 val = subject . async . accessor
231- sleep ( 0.1 )
232233 expect ( val . value ) . to eq :foo
233234 expect ( subject . accessor ) . to eq :foo
234235 end
235236
236237 it 'supports methods with blocks' do
237238 val = subject . async . with_block { :foo }
238- sleep ( 0.1 )
239239 expect ( val . value ) . to eq :foo
240240 end
241241
@@ -244,7 +244,6 @@ def many(*args, &block) nil; end
244244 it 'defines the method after the first call' do
245245 expect { subject . async . method ( :echo ) } . to raise_error ( NameError )
246246 subject . async . echo ( :foo )
247- sleep ( 0.1 )
248247 expect { subject . async . method ( :echo ) } . not_to raise_error
249248 end
250249
0 commit comments