Skip to content

Commit 39c838a

Browse files
OskarEichlerSongstats Dependency Audit
andauthored
Reject serialized execution without a task (#1113)
* Reject serialized execution without a task * Add serialized execution block coverage --------- Co-authored-by: Songstats Dependency Audit <audit@local.invalid>
1 parent a39998d commit 39c838a

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎lib/concurrent-ruby/concurrent/executor/serialized_execution.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def call
3232
#
3333
# @raise [ArgumentError] if no task is given
3434
def post(executor, *args, &task)
35+
raise ArgumentError.new('no block given') unless block_given?
36+
3537
posts [[executor, args, task]]
3638
true
3739
end

‎spec/concurrent/executor/serialized_execution_spec.rb‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
module Concurrent
66

7+
RSpec.describe SerializedExecution do
8+
9+
it 'raises an exception when no block is given' do
10+
expect {
11+
subject.post(ImmediateExecutor.new)
12+
}.to raise_error(ArgumentError, 'no block given')
13+
end
14+
end
15+
716
RSpec.describe SerializedExecutionDelegator do
817

918
subject { SerializedExecutionDelegator.new(ImmediateExecutor.new) }

0 commit comments

Comments
 (0)