Skip to content

Commit bc4fe4b

Browse files
committed
Refactored more specs.
1 parent 18ad2b7 commit bc4fe4b

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

spec/concurrent/future_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def execute_dereferenceable(subject)
5757
end
5858

5959
context 'subclassing' do
60-
60+
6161
subject{ Future.execute(executor: executor){ 42 } }
6262

6363
it 'protects #set' do
@@ -75,7 +75,7 @@ def execute_dereferenceable(subject)
7575

7676
context '#initialize' do
7777

78-
let(:executor) { ImmediateExecutor.new }
78+
let(:executor) { ImmediateExecutor.new }
7979

8080
it 'sets the state to :unscheduled' do
8181
Future.new(executor: executor){ nil }.should be_unscheduled
@@ -111,6 +111,7 @@ def execute_dereferenceable(subject)
111111
context 'instance #execute' do
112112

113113
it 'does nothing unless the state is :unscheduled' do
114+
executor = ImmediateExecutor.new
114115
executor.should_not_receive(:post).with(any_args)
115116
future = Future.new(executor: executor){ nil }
116117
future.instance_variable_set(:@state, :pending)

spec/concurrent/promise_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ module Concurrent
125125
describe 'with children' do
126126

127127
let(:root) { Promise.new(executor: executor){ sleep(0.1); nil } }
128-
let(:c1) { root.then { nil } }
129-
let(:c2) { root.then { nil } }
130-
let(:c2_1) { c2.then { nil } }
128+
let(:c1) { root.then { sleep(0.1); nil } }
129+
let(:c2) { root.then { sleep(0.1); nil } }
130+
let(:c2_1) { c2.then { sleep(0.1); nil } }
131131

132132
context 'when called on the root' do
133133
it 'should set all promises to :pending' do
@@ -142,7 +142,6 @@ module Concurrent
142142

143143
context 'when called on a child' do
144144
it 'should set all promises to :pending' do
145-
pending('intermittently failing')
146145
c2_1.execute
147146

148147
[root, c1, c2, c2_1].each { |p| p.should be_pending }
@@ -336,8 +335,7 @@ module Concurrent
336335
end
337336

338337
it 'uses reason as rejection reason when a promise has no rescue callable' do
339-
pending('intermittently failing')
340-
p = Promise.new(executor: executor){ raise ArgumentError }.then { |val| val }.execute
338+
p = Promise.new(executor: ImmediateExecutor.new){ raise ArgumentError }.then{ |val| val }.execute
341339
sleep(0.1)
342340
p.should be_rejected
343341
p.reason.should be_a ArgumentError

spec/concurrent/thread_pool_executor_shared.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@
145145
end
146146

147147
it 'returns :max_length when stopped' do
148-
pending('intermittently failing')
149-
100.times{ subject.post{ sleep(0.5) } }
148+
100.times{ subject.post{ nil } }
150149
sleep(0.1)
151150
subject.shutdown
152151
subject.wait_for_termination(1)

0 commit comments

Comments
 (0)