From f3d008ef41a39a8e7b5c6985c3b33c67b2e6ead4 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:07:13 +0200 Subject: [PATCH] Add simplecov It's been a while since I added/removed this here. I'm interested again --- .gitignore | 1 + Gemfile | 4 ++++ Gemfile.lock | 8 ++++++++ test/test_helper.rb | 27 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/.gitignore b/.gitignore index ce95a2b..4fb02c7 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ /data /.env /public/build +/coverage diff --git a/Gemfile b/Gemfile index 94f7924..8a27198 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,10 @@ gem "rugged" gem "selenium-webdriver" gem "simple_form" +group :test do + gem "simplecov", require: false +end + group :development, :test do gem "factory_bot", require: false gem "minitest-spec-rails", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 326f0ed..f9bb47c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,7 @@ GEM debug (1.9.1) irb (~> 1.10) reline (>= 0.3.8) + docile (1.4.0) drb (2.2.0) ruby2_keywords erubi (1.12.0) @@ -215,6 +216,12 @@ GEM simple_form (5.3.0) actionpack (>= 5.2) activemodel (>= 5.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.11190) stringio (3.1.0) @@ -269,6 +276,7 @@ DEPENDENCIES rugged selenium-webdriver simple_form + simplecov webmock BUNDLED WITH diff --git a/test/test_helper.rb b/test/test_helper.rb index 5165275..c25bb5e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,33 @@ ENV["RAILS_ENV"] ||= "test" ENV["MT_NO_EXPECTATIONS"] ||= "1" + +require "simplecov" +module SimpleCov + class SourceFile + def coverage_exceeding_source_warn + # no-op, https://github.com/simplecov-ruby/simplecov/issues/1057 + end + end +end + +SimpleCov.start "rails" do + enable_coverage :branch + enable_coverage_for_eval + + groups.delete "Channels" + groups.delete "Mailers" + groups.delete "Libraries" + + add_group "Sites", "app/logical/sites" + add_group "Scraper", "app/logical/scraper" + add_group "Views", "app/views" + add_group "Logical" do |src_file| + not_filtered_further = ["logical/sites", "logical/scraper"].none? { |e| src_file.filename.include? e } + not_filtered_further && src_file.filename.include?("app/logical") + end +end + require_relative "../config/environment" require "rails/test_help" require "minitest-spec-rails"