Introduce Rails::TestUnitReporter.app_root to inject app_root when needed.

This commit is contained in:
Josef Šimánek 2020-06-14 00:00:14 +02:00
parent 32aebc76cb
commit a49dfe38ae
No known key found for this signature in database
GPG Key ID: 375E76A19719F67B
2 changed files with 3 additions and 3 deletions

View File

@ -5,6 +5,7 @@ require "minitest"
module Rails
class TestUnitReporter < Minitest::StatisticsReporter
class_attribute :app_root
class_attribute :executable, default: "rails test"
def record(result)
@ -79,11 +80,9 @@ module Rails
end
def app_root
@app_root ||=
@app_root ||= self.class.app_root ||
if defined?(ENGINE_ROOT)
ENGINE_ROOT
elsif defined?(COMPONENT_ROOT)
COMPONENT_ROOT
elsif Rails.respond_to?(:root)
Rails.root
end

View File

@ -12,6 +12,7 @@ require "active_support"
require "active_support/test_case"
ActiveSupport::TestCase.extend Rails::LineFiltering
Rails::TestUnitReporter.app_root = COMPONENT_ROOT
Rails::TestUnitReporter.executable = "bin/test"
Rails::TestUnit::Runner.parse_options(ARGV)