Skip to content

Commit 0740ba6

Browse files
justin808claude
andcommitted
Fix RuboCop errors in Pro helper spec
Simplified the if/else blocks to avoid RuboCop Layout cop bugs. The Layout cops were crashing on multi-line if/else assignments even though the code had no actual offenses. Changed to simpler variable assignments to avoid the crashes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c8915f6 commit 0740ba6

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,11 @@ def mock_request_and_response(mock_chunks = chunks, count: 1)
374374
initial_result = stream_react_component(component_name, props: props, **component_options)
375375
expect(initial_result).to include(react_component_div_with_initial_chunk)
376376
# consoleReplayScript is now wrapped in a script tag with id="consoleReplayLog"
377-
wrapped_first_console_script = if chunks.first[:consoleReplayScript].present?
378-
"<script id=\"consoleReplayLog\">" \
379-
"#{chunks.first[:consoleReplayScript]}</script>"
380-
else
381-
""
382-
end
383-
expect(initial_result).to include(wrapped_first_console_script) if wrapped_first_console_script.present?
377+
if chunks.first[:consoleReplayScript].present?
378+
script = chunks.first[:consoleReplayScript]
379+
wrapped = "<script id=\"consoleReplayLog\">#{script}</script>"
380+
expect(initial_result).to include(wrapped)
381+
end
384382
expect(initial_result).not_to include("More content", "Final content")
385383
expect(chunks_read.count).to eq(1)
386384
end
@@ -395,14 +393,10 @@ def mock_request_and_response(mock_chunks = chunks, count: 1)
395393
second_result = fiber.resume
396394
# regex that matches the html and wrapped consoleReplayScript
397395
# Note: consoleReplayScript is now wrapped in a script tag with id="consoleReplayLog"
398-
wrapped_console_script = if chunks[1][:consoleReplayScript].present?
399-
"<script id=\"consoleReplayLog\">" \
400-
"#{chunks[1][:consoleReplayScript]}</script>"
401-
else
402-
""
403-
end
396+
script = chunks[1][:consoleReplayScript]
397+
wrapped = script.present? ? "<script id=\"consoleReplayLog\">#{script}</script>" : ""
404398
expect(second_result).to match(
405-
/#{Regexp.escape(chunks[1][:html])}\s+#{Regexp.escape(wrapped_console_script)}/
399+
/#{Regexp.escape(chunks[1][:html])}\s+#{Regexp.escape(wrapped)}/
406400
)
407401
expect(second_result).not_to include("Stream React Server Components", "Final content")
408402
expect(chunks_read.count).to eq(2)

0 commit comments

Comments
 (0)