Skip to content

Commit 9c7927f

Browse files
yhk1038claude
andcommitted
fix(test): properly handle SystemExit in CLI spec
The test was using `rescue StandardError` which doesn't catch SystemExit (a subclass of Exception, not StandardError). This caused unhandled exits that propagated to RSpec, resulting in exit code 1 despite 0 test failures. Changed to use RSpec's compound matcher `.to output().to_stdout.and raise_error(SystemExit)` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent d4d46ce commit 9c7927f

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

spec/t_ruby/cli_spec.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,9 @@
131131
it "displays error message" do
132132
cli = TRuby::CLI.new(["/nonexistent/file.trb"])
133133

134-
output = begin
135-
capture_stderr { cli.run }
136-
rescue StandardError
137-
nil
138-
end
139-
stdout = begin
140-
capture_stdout { cli.run }
141-
rescue StandardError
142-
nil
143-
end
144-
145-
combined_output = (output || "") + (stdout || "")
146-
expect(combined_output).to include("Error:")
134+
expect do
135+
cli.run
136+
end.to output(/Error:/).to_stdout.and raise_error(SystemExit)
147137
end
148138

149139
it "exits with status 1" do

0 commit comments

Comments
 (0)