-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SimpleCov config for guard MiniTest
The code coverage analysis tool did not correctly report test coverage results if executed via guard-minitest. Externalizing the config into `.simplecov` is considered best practice: simplecov-ruby/simplecov#235 (comment) The `.simplecov` config is optimized for Cloud Stove based on the Rails defaults from: https://github.com/colszowka/simplecov/blob/master/lib/simplecov/defaults.rb Positive side effect: Adding Spring support for MiniTest accelerates repeated test executions through reloading: https://github.com/guard/guard-minitest#spring The new Rake task `rake test:coverage` also triggers coverage analysis. SimpleCov is very fast (i.e., a couple of seconds for ~10 min Rails test suite) and thus they enable coverage analysis by default. For conditional execution, see: https://github.com/colszowka/simplecov#running-coverage-only-on-demand
- Loading branch information
Showing
5 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config | ||
# Maybe put some conditional here not to execute the code below unless ENV['COVERAGE'] == 'true' | ||
SimpleCov.start do | ||
# see https://github.com/colszowka/simplecov/blob/master/lib/simplecov/defaults.rb | ||
load_profile 'test_frameworks' | ||
coverage_dir 'coverage' | ||
command_name 'MiniTest' | ||
merge_timeout 3600 # 1 hour | ||
track_files "{app,lib}/**/*.rb" | ||
|
||
# Groups | ||
add_group 'Controllers', 'app/controllers' | ||
add_group 'Models', 'app/models' | ||
# add_group 'Mailers', 'app/mailers' | ||
add_group 'Helpers', 'app/helpers' | ||
add_group 'Jobs', %w(app/jobs app/workers) | ||
# add_group 'Libraries', 'lib' | ||
|
||
add_group 'Provider updater', 'app/provider_updater' | ||
add_group 'Long files' do |src_file| | ||
src_file.lines.count > 100 | ||
end | ||
class MaxLinesFilter < SimpleCov::Filter | ||
def matches?(source_file) | ||
source_file.lines.count < filter_argument | ||
end | ||
end | ||
add_group 'Short files', MaxLinesFilter.new(5) | ||
|
||
# Exclude these paths from analysis | ||
add_filter '/config/' | ||
add_filter '/db/' | ||
add_filter 'lib/plugins' | ||
add_filter 'vendor' | ||
add_filter 'bundle' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Usage: `rake test:coverage` | ||
namespace :test do | ||
task :coverage do | ||
require 'simplecov' | ||
Rake::Task['test'].execute | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters