Skip to content

Commit d1c9028

Browse files
ihabadhamclaude
andcommitted
Fix test mocks to support stream.closed? checks
Commit 0815ce0 added stream.closed? checks to prevent wasted work after client disconnect, but the test mocks didn't stub this method, causing all streaming tests to fail with: #<InstanceDouble(ActionController::Live::Buffer)> received unexpected message :closed? with (no args) Changes: - Stub .closed? to return false in helper_spec.rb test setup - Stub .closed? to return false in stream_spec.rb setup_stream_test - Update spec/dummy/Gemfile.lock to include async gem dependencies (needed when running bundle install in spec/dummy directory) This fixes 14 failing tests: - 10 failures in react_on_rails_pro_helper_spec.rb - 4 failures in stream_spec.rb 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9b536a4 commit d1c9028

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

react_on_rails_pro/spec/dummy/Gemfile.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PATH
2222
specs:
2323
react_on_rails_pro (16.2.0.beta.4)
2424
addressable
25+
async (>= 2.6)
2526
connection_pool
2627
execjs (~> 2.9)
2728
httpx (~> 1.5)
@@ -107,6 +108,12 @@ GEM
107108
public_suffix (>= 2.0.2, < 7.0)
108109
amazing_print (1.6.0)
109110
ast (2.4.2)
111+
async (2.34.0)
112+
console (~> 1.29)
113+
fiber-annotation
114+
io-event (~> 1.11)
115+
metrics (~> 0.12)
116+
traces (~> 0.18)
110117
base64 (0.2.0)
111118
benchmark (0.4.0)
112119
bigdecimal (3.1.9)
@@ -131,6 +138,10 @@ GEM
131138
coderay (1.1.3)
132139
concurrent-ruby (1.3.5)
133140
connection_pool (2.5.0)
141+
console (1.34.2)
142+
fiber-annotation
143+
fiber-local (~> 1.1)
144+
json
134145
coveralls (0.8.23)
135146
json (>= 1.8, < 3)
136147
simplecov (~> 0.16.1)
@@ -165,6 +176,9 @@ GEM
165176
ffi (1.17.0-x86_64-darwin)
166177
ffi (1.17.0-x86_64-linux-gnu)
167178
ffi (1.17.0-x86_64-linux-musl)
179+
fiber-annotation (0.2.0)
180+
fiber-local (1.1.0)
181+
fiber-storage
168182
fiber-storage (1.0.0)
169183
generator_spec (0.10.0)
170184
activesupport (>= 3.0.0)
@@ -184,6 +198,7 @@ GEM
184198
i18n (1.14.7)
185199
concurrent-ruby (~> 1.0)
186200
io-console (0.8.0)
201+
io-event (1.14.0)
187202
irb (1.15.1)
188203
pp (>= 0.6.0)
189204
rdoc (>= 4.0.0)
@@ -216,6 +231,7 @@ GEM
216231
marcel (1.0.4)
217232
matrix (0.4.2)
218233
method_source (1.1.0)
234+
metrics (0.15.0)
219235
mini_mime (1.1.5)
220236
mini_portile2 (2.8.8)
221237
minitest (5.25.4)
@@ -447,6 +463,7 @@ GEM
447463
tins (1.33.0)
448464
bigdecimal
449465
sync
466+
traces (0.18.2)
450467
turbolinks (5.2.1)
451468
turbolinks-source (~> 5.2)
452469
turbolinks-source (5.2.0)

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)
@@ -583,6 +584,7 @@ def execute_stream_view_containing_react_components
583584
written_chunks.clear
584585
allow(mocked_stream).to receive(:write) { |chunk| written_chunks << chunk }
585586
allow(mocked_stream).to receive(:close)
587+
allow(mocked_stream).to receive(:closed?).and_return(false)
586588
mocked_response = instance_double(ActionDispatch::Response)
587589
allow(mocked_response).to receive(:stream).and_return(mocked_stream)
588590
allow(self).to receive(:response).and_return(mocked_response)

react_on_rails_pro/spec/react_on_rails_pro/stream_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ def setup_stream_test(component_count: 2)
388388
allow(mocked_response).to receive(:stream).and_return(mocked_stream)
389389
allow(mocked_stream).to receive(:write)
390390
allow(mocked_stream).to receive(:close)
391+
allow(mocked_stream).to receive(:closed?).and_return(false)
391392
allow(controller).to receive(:response).and_return(mocked_response)
392393

393394
[component_queues, controller, mocked_stream]

0 commit comments

Comments
 (0)