@@ -33,7 +33,7 @@ def dereferenceable_observable(opts = {})
3333 end
3434
3535 def execute_dereferenceable ( subject )
36- subject << proc { ' value' }
36+ subject . post { | value | 10 }
3737 sleep ( 0.1 )
3838 end
3939
@@ -42,6 +42,8 @@ def execute_dereferenceable(subject)
4242
4343 context '#initialize' do
4444
45+ let ( :executor ) { ImmediateExecutor . new }
46+
4547 it 'sets the value to the given initial state' do
4648 Agent . new ( 10 ) . value . should eq 10
4749 end
@@ -54,13 +56,29 @@ def execute_dereferenceable(subject)
5456 Agent . new ( 0 ) . timeout . should eq Agent ::TIMEOUT
5557 end
5658
57- it 'uses the executor given with the :executor option'
59+ it 'uses the executor given with the :executor option' do
60+ executor . should_receive ( :post ) . with ( any_args ) . and_return ( 0 )
61+ agent = Agent . new ( 0 , executor : executor )
62+ agent . post { |value | 0 }
63+ end
5864
59- it 'uses the global operation pool when :operation is true'
65+ it 'uses the global operation pool when :operation is true' do
66+ Concurrent . configuration . should_receive ( :global_operation_pool ) . and_return ( executor )
67+ agent = Agent . new ( 0 , operation : true )
68+ agent . post { |value | 0 }
69+ end
6070
61- it 'uses the global task pool when :task is true'
71+ it 'uses the global task pool when :task is true' do
72+ Concurrent . configuration . should_receive ( :global_task_pool ) . and_return ( executor )
73+ agent = Agent . new ( 0 , task : true )
74+ agent . post { |value | 0 }
75+ end
6276
63- it 'uses the global task pool by default'
77+ it 'uses the global task pool by default' do
78+ Concurrent . configuration . should_receive ( :global_task_pool ) . and_return ( executor )
79+ agent = Agent . new ( 0 )
80+ agent . post { |value | 0 }
81+ end
6482 end
6583
6684 context '#rescue' do
0 commit comments