Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

Add simplecov (#760)

Zach Gollwitzer22e6919eb5c1
diff --git a/.gitignore b/.gitignore
index 60c70a2b..c65d3262 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,3 +53,5 @@ compose-dev.yaml
# Ignore GCP keyfile
gcp-storage-keyfile.json
+
+coverage
diff --git a/Gemfile b/Gemfile
index eda3e623..1adb7b69 100644
--- a/Gemfile
+++ b/Gemfile
@@ -71,4 +71,5 @@ group :test do
gem "vcr"
gem "webmock"
gem "climate_control"
+ gem "simplecov", require: false
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 9a02111e..f4b76c4f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -171,6 +171,7 @@ GEM
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
+ docile (1.4.0)
dotenv (3.1.2)
dotenv-rails (3.1.2)
dotenv (= 3.1.2)
@@ -399,6 +400,12 @@ GEM
sentry-ruby (5.17.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
+ simplecov (0.22.0)
+ docile (~> 1.1)
+ simplecov-html (~> 0.11)
+ simplecov_json_formatter (~> 0.1)
+ simplecov-html (0.12.3)
+ simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
sorbet-runtime (0.5.11383)
stackprof (0.2.26)
@@ -493,6 +500,7 @@ DEPENDENCIES
selenium-webdriver
sentry-rails
sentry-ruby
+ simplecov
stackprof
stimulus-rails
tailwindcss-rails
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 0f5895dd..c37d06a4 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,3 +1,10 @@
+if ENV["COVERAGE"]
+ require "simplecov"
+ SimpleCov.start "rails" do
+ enable_coverage :branch
+ end
+end
+
# Test ENV setup:
# By default, all features should be disabled
# Use the `with_env_overrides` helper to enable features for individual tests
@@ -28,6 +35,17 @@ module ActiveSupport
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
+ # https://github.com/simplecov-ruby/simplecov/issues/718#issuecomment-538201587
+ if ENV["COVERAGE"]
+ parallelize_setup do |worker|
+ SimpleCov.command_name "#{SimpleCov.command_name}-#{worker}"
+ end
+
+ parallelize_teardown do |worker|
+ SimpleCov.result
+ end
+ end
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all