Skip to content

Commit 32daa47

Browse files
committed
👷 Make SimpleCov work with MiniTest
- simplecov-ruby/simplecov#1112
1 parent 0892e54 commit 32daa47

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

.envrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ PATH_add bin
1717
### External Testing Controls
1818
export K_SOUP_COV_DO=true # Means you want code coverage
1919
# Available formats are html, xml, rcov, lcov, json, tty
20-
export K_SOUP_COV_COMMAND_NAME="RSpec Coverage"
20+
export K_SOUP_COV_COMMAND_NAME="Minitest Coverage"
2121
export K_SOUP_COV_FORMATTERS="html,tty"
22-
export K_SOUP_COV_MIN_BRANCH=2 # Means you want to enforce X% branch coverage
23-
export K_SOUP_COV_MIN_LINE=46 # Means you want to enforce X% line coverage
22+
export K_SOUP_COV_MIN_BRANCH=69 # Means you want to enforce X% branch coverage
23+
export K_SOUP_COV_MIN_LINE=88 # Means you want to enforce X% line coverage
2424
export K_SOUP_COV_MIN_HARD=true # Means you want the build to fail if the coverage thresholds are not met
2525
export K_SOUP_COV_MULTI_FORMATTERS=true
2626
export MAX_ROWS=1 # Setting for simplecov-console gem for tty output, limits to the worst N rows of bad coverage
2727

28+
# External Debugging Controls
29+
export REQUIRE_BENCH=false
30+
2831
# Internal Debugging Controls
2932
export DEBUG=false # do not allow byebug statements (override in .env.local)
3033

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
/pkg/
77
/tmp/
88

9+
# Debugging
10+
.byebug_history
11+
912
# rspec failure tracking
1013
.rspec_status
1114

.simplecov

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
require "kettle/soup/cover/config"
1+
require "kettle/soup/cover/config" # This lives in the kettle-soup-cover gem!
2+
require "minitest/simplecov_plugin" # This lives in the simplecov gem!
3+
4+
Minitest.plugin_simplecov_init({})
25

36
SimpleCov.start

test/test_helper.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@
66
require "minitest/autorun"
77
require "mocha/minitest"
88

9-
# Internal test config
10-
require "config/debug.rb"
11-
12-
# Last thing before loading this gem is to set up code coverage
9+
# We have to set up code coverage early because the gem will be required by the Rails test dummy app.
1310
begin
1411
# This does not require "simplecov", but
1512
require "kettle-soup-cover"
1613
# this next line has a side effect of running `.simplecov`
1714
require "simplecov" if defined?(Kettle::Soup::Cover) && Kettle::Soup::Cover::DO_COV
1815
rescue LoadError
19-
nil
16+
warn("Warning: Could not load simplecov. Code coverage will not be collected.")
2017
end
2118

19+
# Internal test config
20+
require "config/debug.rb"
21+
22+
require "bundler"
23+
Bundler.require :default, :development
24+
2225
# External Libs that Rails, or other deps, are dependent on,
2326
# yet not all versions of Rails, or other deps, require properly
2427
require "logger"
2528
require "rexml"
2629

27-
require "bundler"
28-
Bundler.require :default, :development
2930
Combustion.path = "test/internal"
3031
Combustion.initialize!(:all)
3132

@@ -35,8 +36,6 @@
3536

3637
puts "Rails version is #{Rails.version}"
3738
puts "BUNDLE_GEMFILE: #{ENV["BUNDLE_GEMFILE"]}"
38-
puts "RAILS_VERSION: #{ENV["RAILS_VERSION"]}"
39-
puts "RAILS_MAJOR_MINOR: #{ENV["RAILS_MAJOR_MINOR"]}"
4039

4140
require "masq2"
4241

0 commit comments

Comments
 (0)