Skip to content

Commit

Permalink
Wrote pending specs for Future#execute refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jdantonio committed Feb 7, 2014
1 parent fb28d0d commit 7a8a852
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions spec/concurrent/future_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ module Concurrent

context '#initialize' do

it 'spawns a new thread when a block is given' do
Future.thread_pool.should_receive(:post).once.with(any_args)
it 'sets the state to :unscheduled'

it 'does not spawn a new thread when a block is given' do
Future.thread_pool.should_not_receive(:post).once.with(any_args)
Thread.should_not_receive(:new).with(any_args)
Future.new{ nil }
end

it 'does not spawns a new thread when no block given' do
it 'does not spawn a new thread when no block given' do
Future.thread_pool.should_not_receive(:post).once.with(any_args)
Thread.should_not_receive(:new).with(any_args)
Future.new
end
Expand All @@ -56,6 +60,29 @@ module Concurrent
end
end

context 'instance #execute' do

it 'does nothing unless the state is :unscheduled'

it 'spawns a new thread when a block was given on construction'

it 'sets the sate to :pending'

it 'returns self'

end

context 'class #execute' do

it 'creates a new Future'

it 'passes the block to Future'

it 'calls #execute on the new Future'

it 'returns the new Future'
end

context 'fulfillment' do

before(:each) do
Expand Down

0 comments on commit 7a8a852

Please sign in to comment.