Skip to content

Commit

Permalink
catch rspec runtimes failures in check_rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Oct 8, 2013
1 parent d2ce73e commit e34b73a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/check_rspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions features/check_rspec/run.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.+$
"""

0 comments on commit e34b73a

Please sign in to comment.