Skip to content

Commit 6595ea7

Browse files
committed
Refactored brittle dereferenceable specs.
1 parent 11e5fc2 commit 6595ea7

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

spec/concurrent/dereferenceable_shared.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,6 @@
117117
subject.value.should be_nil
118118
end
119119

120-
it 'locks when all options are false' do
121-
subject = dereferenceable_subject(0)
122-
mutex = double('mutex')
123-
subject.stub(:mutex).and_return(mutex)
124-
mutex.should_receive(:lock).at_least(:once)
125-
mutex.should_receive(:unlock).at_least(:once)
126-
subject.value
127-
end
128-
129120
it 'supports dereference flags with observers', :brittle, :refactored do
130121

131122
if dereferenceable_subject(0).respond_to?(:add_observer)

spec/concurrent/scheduled_task_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ module Concurrent
3939
# dereferenceable
4040

4141
def dereferenceable_subject(value, opts = {})
42-
ScheduledTask.execute(0.1, opts){ value }.tap{ sleep(0.2) }
42+
latch = Concurrent::CountDownLatch.new(1)
43+
task = ScheduledTask.execute(0.1, opts){ value }.tap{ latch.count_down }
44+
latch.wait(1)
45+
task
4346
end
4447

4548
def dereferenceable_observable(opts = {})

0 commit comments

Comments
 (0)