In a Rails application tested with RSpec (using the rspec-rails
gem) the
coverage report is not generated after the test suite has run.
- Clone this repo & run
bundle install
- Run
bundle exec rspec
- Comment/uncomment the
require "active_support/test_case"
inspec/foo_spec.rb
to observe the issue
When ActiveSupport::TestCase
is required, by RSpec Rails for example:
This ends up requiring minitest
:
Unfortunately Minitest is a dependency of ActiveSupport:
By having defined Minitest
, this means the SimpleCov at_exit
hook will skip
the 'at exit behaviour' hook:
at_exit do
# Exit hook for Minitest defined in Minitest plugin
next if defined?(Minitest)
SimpleCov.at_exit_behavior
end
PRs which introduced this behaviour:
RSpec.configure do |config|
config.after(:suite) { SimpleCov.at_exit_behavior }
end