Skip to content

Commit 45fd716

Browse files
justin808claude
andcommitted
Simplify integration test to use IOError instead of mocking HTTPx errors
Instead of trying to create complex mock HTTPX::ErrorResponse and HTTPX::HTTPError objects (which require many internal stubs), simply raise an IOError to simulate a connection failure. StreamRequest catches any error during streaming and retries, so the specific error type doesn't matter for testing the retry behavior. This approach is much simpler and more maintainable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent eed296c commit 45fd716

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

react_on_rails_pro/spec/react_on_rails_pro/request_spec.rb

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -245,25 +245,9 @@
245245
# This simulates a connection error after partial data is sent
246246
mock_streaming_response(render_full_url, 200) do |yielder|
247247
yielder.call("#{original_chunks[0]}\n")
248-
# Simulate connection error mid-stream by creating a mock error response
249-
# Create a minimal mock request object that satisfies the ErrorResponse constructor
250-
mock_options = instance_double(
251-
HTTPX::Options,
252-
timeout: {},
253-
debug_level: 0,
254-
debug: false
255-
)
256-
mock_request = instance_double(
257-
HTTPX::Request,
258-
uri: URI(render_full_url),
259-
response: nil,
260-
options: mock_options
261-
)
262-
error_response = HTTPX::ErrorResponse.new(
263-
mock_request,
264-
StandardError.new("Connection closed")
265-
)
266-
raise HTTPX::HTTPError, error_response
248+
# Simulate connection error mid-stream
249+
# StreamRequest catches any error and retries, so we can use a simple error
250+
raise IOError, "Connection closed"
267251
end
268252
else
269253
# Second attempt: complete all chunks successfully

0 commit comments

Comments
 (0)