Skip to content

Commit

Permalink
Merge pull request #84 from crealytics/master
Browse files Browse the repository at this point in the history
Fix issue #41
  • Loading branch information
colszowka committed Sep 28, 2011
2 parents 28c0d89 + 5ece56c commit 24ced99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions features/rspec_fails_on_initialization.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@rspec
Feature:

Running specs with a failing rspec setup

Scenario: Fail if rspec fails before starting its tests
Given a file named "spec/spec_helper.rb" with:
"""
require 'simplecov'
SimpleCov.start
raise "some exception in the class loading before the tests start"
"""
When I run `bundle exec rspec spec`
Then the exit status should not be 0
8 changes: 6 additions & 2 deletions lib/simplecov/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@
# Exclude files outside of SimpleCov.root
load_adapter 'root_filter'
end

at_exit do
# Store the exit status of the test run since it goes away after calling the at_exit proc...
@exit_status = $!.status if $!.is_a?(SystemExit)
if $! #was an exception thrown?
#if it was a SystemExit, use the accompanying status
#otherwise set a non-zero status representing termination by some other exception
#(see github issue 41)
@exit_status = $!.is_a?(SystemExit) ? $!.status : 1
end
SimpleCov.at_exit.call
exit @exit_status if @exit_status # Force exit with stored status (see github issue #5)
end
Expand Down

0 comments on commit 24ced99

Please sign in to comment.