summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-01-28 08:49:46 -0800
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-01-30 12:26:19 +1300
commitac2fdb250e053714c86edc32617ff58fa7bd3e3a (patch)
treec814b89c62dbbac129ecf5aa54e30bfd118ade98
parentc6104619d0e3c841c68bd7eefc613ca2376dcf58 (diff)
downloadrack-ac2fdb250e053714c86edc32617ff58fa7bd3e3a.tar.gz
Add test coverage using test_cov rake task
Currently: 3352 / 3602 LOC (93.06%) covered
-rw-r--r--Rakefile6
-rw-r--r--test/helper.rb14
2 files changed, 20 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index 3a232cc5..6ad8d1f0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -92,6 +92,12 @@ Rake::TestTask.new("test:regular") do |t|
t.verbose = true
end
+desc "Run tests with coverage"
+task "test_cov" do
+ ENV['COVERAGE'] = '1'
+ Rake::Task['test:regular'].invoke
+end
+
desc "Run all the fast + platform agnostic tests"
task test: %w[spec test:regular]
diff --git a/test/helper.rb b/test/helper.rb
index 7e43aa8a..c13a71f0 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -1,5 +1,19 @@
# frozen_string_literal: true
+if ENV.delete('COVERAGE')
+ require 'coverage'
+ require 'simplecov'
+
+ def SimpleCov.rack_coverage(**opts)
+ start do
+ add_filter "/test/"
+ add_group('Missing'){|src| src.covered_percent < 100}
+ add_group('Covered'){|src| src.covered_percent == 100}
+ end
+ end
+ SimpleCov.rack_coverage
+end
+
$:.unshift(File.expand_path('../lib', __dir__))
require_relative '../lib/rack'
require 'minitest/global_expectations/autorun'