44# Copyright, 2025, by Samuel Williams.
55
66require "async/container/supervisor/connection"
7+ require "sus/fixtures/async/scheduler_context"
78require "stringio"
89
910class TestTarget
@@ -25,7 +26,7 @@ def dispatch(call)
2526 stream . write ( JSON . dump ( { id : 1 , do : :test } ) << "\n " )
2627 stream . rewind
2728
28- expect ( stream ) . to receive ( :write ) . and_raise ( IOError , "Test error" )
29+ expect ( stream ) . to receive ( :write ) . and_raise ( IOError , "Write error" )
2930
3031 target = TestTarget . new do |call |
3132 Async do
@@ -44,15 +45,15 @@ def dispatch(call)
4445 stream . write ( JSON . dump ( { id : 1 , do : :test } ) << "\n " )
4546 stream . rewind
4647
47- expect ( stream ) . to receive ( :write ) . and_raise ( IOError , "Test error" )
48+ expect ( stream ) . to receive ( :write ) . and_raise ( IOError , "Write error" )
4849
4950 task = nil
5051
5152 target = TestTarget . new do |call |
5253 task = Async do
5354 while true
5455 call . push ( status : "working" )
55- sleep ( 1 ) # Loop forever (until the queue is closed).
56+ sleep ( 0.001 ) # Loop forever (until the queue is closed).
5657 end
5758 end
5859 end
@@ -63,13 +64,17 @@ def dispatch(call)
6364 expect ( task ) . to be ( :failed? )
6465 expect { task . wait } . to raise_exception ( ClosedQueueError )
6566 end
67+ end
68+
69+ with "call" do
70+ include Sus ::Fixtures ::Async ::SchedulerContext
6671
6772 it "handles failed writes when making a call" do
68- expect ( stream ) . to receive ( :write ) . and_raise ( IOError , "Test error" )
73+ expect ( stream ) . to receive ( :write ) . and_raise ( IOError , "Write error" )
6974
7075 expect do
7176 connection . call ( do : :test )
72- end . to raise_exception ( IOError , message : be =~ /Test error/ )
77+ end . to raise_exception ( IOError , message : be =~ /Write error/ )
7378
7479 expect ( connection . calls ) . to be ( :empty? )
7580 end
0 commit comments