Skip to content

Commit decc75e

Browse files
Add closed? method stub to streaming test mocks
Fixes 9 failing tests in react_on_rails_pro_helper_spec.rb by adding the closed? method stub to mocked streams. The production code now checks response.stream.closed? for client disconnect detection, so test mocks need to support this method. Changes: - Add closed? stub returning false to stream_view_containing_react_components tests - Add closed? stub returning false to cached_stream_react_component tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Abanoub Ghadban <AbanoubGhadban@users.noreply.github.com>
1 parent 763a9ff commit decc75e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

react_on_rails_pro/spec/dummy/spec/helpers/react_on_rails_pro_helper_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ def mock_request_and_response(mock_chunks = chunks, count: 1)
443443
written_chunks << chunk
444444
end
445445
allow(mocked_stream).to receive(:close)
446+
allow(mocked_stream).to receive(:closed?).and_return(false)
446447
mocked_response = instance_double(ActionDispatch::Response)
447448
allow(mocked_response).to receive(:stream).and_return(mocked_stream)
448449
allow(self).to receive(:response).and_return(mocked_response)
@@ -532,6 +533,7 @@ def execute_stream_view_containing_react_components
532533
written_chunks.clear
533534
allow(mocked_stream).to receive(:write) { |chunk| written_chunks << chunk }
534535
allow(mocked_stream).to receive(:close)
536+
allow(mocked_stream).to receive(:closed?).and_return(false)
535537
mocked_response = instance_double(ActionDispatch::Response)
536538
allow(mocked_response).to receive(:stream).and_return(mocked_stream)
537539
allow(self).to receive(:response).and_return(mocked_response)

0 commit comments

Comments
 (0)