diff --git a/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb b/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb index 4db7c7f0c..c496afee6 100644 --- a/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb +++ b/lib/concurrent-ruby/concurrent/executor/serialized_execution.rb @@ -32,6 +32,8 @@ def call # # @raise [ArgumentError] if no task is given def post(executor, *args, &task) + raise ArgumentError.new('no block given') unless block_given? + posts [[executor, args, task]] true end diff --git a/spec/concurrent/executor/serialized_execution_spec.rb b/spec/concurrent/executor/serialized_execution_spec.rb index 11b9bc72c..efe605f15 100644 --- a/spec/concurrent/executor/serialized_execution_spec.rb +++ b/spec/concurrent/executor/serialized_execution_spec.rb @@ -4,6 +4,15 @@ module Concurrent + RSpec.describe SerializedExecution do + + it 'raises an exception when no block is given' do + expect { + subject.post(ImmediateExecutor.new) + }.to raise_error(ArgumentError, 'no block given') + end + end + RSpec.describe SerializedExecutionDelegator do subject { SerializedExecutionDelegator.new(ImmediateExecutor.new) }