diff --git a/bin/check_rspec b/bin/check_rspec index df7371c..859f8d7 100755 --- a/bin/check_rspec +++ b/bin/check_rspec @@ -36,7 +36,14 @@ rescue Timeout::Error exit EXIT_CRITICAL end -puts cmd_stdout +if cmd_stdout.length > 0 + puts cmd_stdout +else + # if nothing was output on stdout, print the first line of stderr + puts "RSPEC Critical - #{cmd_stderr.split("\n")[0]}" + exit EXIT_CRITICAL +end + unless cmd_status.exitstatus == 0 exit EXIT_CRITICAL end diff --git a/features/check_rspec/run.feature b/features/check_rspec/run.feature index 12a13e2..9aad52a 100644 --- a/features/check_rspec/run.feature +++ b/features/check_rspec/run.feature @@ -29,3 +29,15 @@ Scenario: run a failing rspec test """ ^RSPEC Critical - 1 example, 1 failures, finished in 0.\d+ seconds | examples=1 passing=0 failures=1 pending=0 conformance=0% time=0.\d+s$ """ + +Scenario: rspec dies + Given a file named "trivial_spec.rb" with: + """ + raise RuntimeError + """ + When I run `check_rspec trivial_spec.rb` + Then the exit status should be 2 + And it should fail with regexp: + """ + ^RSPEC Critical -.+RuntimeError.+$ + """