From 04121bd02059b8246233d0421349005d75a6b1a1 Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Wed, 15 Nov 2023 18:09:31 -0500
Subject: [PATCH] Disable simplecov `enable_coverage_for_eval` option, move to
 standalone file (#27869)

---
 .simplecov          | 22 ++++++++++++++++++++++
 spec/spec_helper.rb | 25 ++-----------------------
 2 files changed, 24 insertions(+), 23 deletions(-)
 create mode 100644 .simplecov

diff --git a/.simplecov b/.simplecov
new file mode 100644
index 000000000..fbd0207be
--- /dev/null
+++ b/.simplecov
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+if ENV['CI']
+  require 'simplecov-lcov'
+  SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
+  SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
+else
+  SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
+end
+
+SimpleCov.start 'rails' do
+  enable_coverage :branch
+
+  add_filter 'lib/linter'
+
+  add_group 'Libraries', 'lib'
+  add_group 'Policies', 'app/policies'
+  add_group 'Presenters', 'app/presenters'
+  add_group 'Serializers', 'app/serializers'
+  add_group 'Services', 'app/services'
+  add_group 'Validators', 'app/validators'
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 0bb4f88cf..dc60976d0 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,28 +1,7 @@
 # frozen_string_literal: true
 
-if ENV['DISABLE_SIMPLECOV'] != 'true'
-  require 'simplecov'
-
-  if ENV['CI']
-    require 'simplecov-lcov'
-    SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
-    SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
-  else
-    SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
-  end
-  SimpleCov.start 'rails' do
-    enable_coverage :branch
-    enable_coverage_for_eval
-
-    add_filter 'lib/linter'
-    add_group 'Policies', 'app/policies'
-    add_group 'Presenters', 'app/presenters'
-    add_group 'Serializers', 'app/serializers'
-    add_group 'Services', 'app/services'
-    add_group 'Validators', 'app/validators'
-
-    add_group 'Libraries', 'lib'
-  end
+unless ENV['DISABLE_SIMPLECOV'] == 'true'
+  require 'simplecov' # Configuration details loaded from .simplecov
 end
 
 RSpec.configure do |config|