Skip to content

Commit 5d7f777

Browse files
committed
Added more tests for Async.
1 parent b4a59b3 commit 5d7f777

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

spec/concurrent/async_spec.rb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,31 @@ def many(*args, &block) nil; end
100100
end
101101
end
102102

103-
context '#executor' do
103+
context 'executor' do
104104

105-
it 'returns the default executor when #executor= has never been called'
106-
107-
it 'returns the memo after #executor= has been called'
108-
end
109-
110-
context '#executor=' do
105+
it 'returns the default executor when #executor= has never been called' do
106+
Concurrent.configuration.should_receive(:global_task_pool).
107+
and_return(ImmediateExecutor.new)
108+
subject = async_class.new
109+
subject.async.echo(:foo)
110+
end
111111

112-
it 'memoizes the given executor'
112+
it 'returns the memo after #executor= has been called' do
113+
executor = ImmediateExecutor.new
114+
executor.should_receive(:post)
115+
subject = async_class.new
116+
subject.executor = executor
117+
subject.async.echo(:foo)
118+
end
113119

114-
it 'raises an exception if called multiple times'
120+
it 'raises an exception if #executor= is called multiple times' do
121+
executor = ImmediateExecutor.new
122+
subject = async_class.new
123+
subject.executor = executor
124+
expect {
125+
subject.executor = executor
126+
}.to raise_error(ArgumentError)
127+
end
115128
end
116129

117130
context '#async' do
@@ -140,7 +153,13 @@ def many(*args, &block) nil; end
140153
val.should be_pending
141154
end
142155

143-
it 'runs the Future on the memoized executor'
156+
it 'runs the Future on the memoized executor' do
157+
executor = ImmediateExecutor.new
158+
executor.should_receive(:post).with(any_args)
159+
subject = async_class.new
160+
subject.executor = executor
161+
subject.async.echo(:foo)
162+
end
144163

145164
it 'sets the value on success' do
146165
val = subject.async.echo(:foo)

0 commit comments

Comments
 (0)