aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/commands/test.rb14
-rw-r--r--railties/lib/rails/test_unit/runner.rb10
2 files changed, 11 insertions, 13 deletions
diff --git a/railties/lib/rails/commands/test.rb b/railties/lib/rails/commands/test.rb
index cd1192eb6e..1efd010dc7 100644
--- a/railties/lib/rails/commands/test.rb
+++ b/railties/lib/rails/commands/test.rb
@@ -1,19 +1,7 @@
ENV["RAILS_ENV"] = "test"
require "rails/test_unit/runner"
-require "rails/test_unit/reporter"
options = Rails::TestRunner::Options.parse(ARGV)
$: << File.expand_path("../../test", APP_PATH)
-$runner = Rails::TestRunner.new(options)
-
-def Minitest.plugin_rails_init(options)
- self.reporter << Rails::TestUnitReporter.new(options[:io], options)
- if method = $runner.find_method
- options[:filter] = method
- end
-end
-Minitest.extensions << 'rails'
-
-# Config Rails backtrace in tests.
-$runner.run
+Rails::TestRunner.new(options).run
diff --git a/railties/lib/rails/test_unit/runner.rb b/railties/lib/rails/test_unit/runner.rb
index c76bd58d22..31ce94a503 100644
--- a/railties/lib/rails/test_unit/runner.rb
+++ b/railties/lib/rails/test_unit/runner.rb
@@ -2,6 +2,7 @@ require "ostruct"
require "optparse"
require "rake/file_list"
require "method_source"
+require "rails/test_unit/reporter"
module Rails
class TestRunner
@@ -59,6 +60,15 @@ module Rails
def run
enable_backtrace if @options[:backtrace]
+ $rails_test_runner = self
+ def Minitest.plugin_rails_init(options)
+ self.reporter << Rails::TestUnitReporter.new(options[:io], options)
+ if method = $rails_test_runner.find_method
+ options[:filter] = method
+ end
+ end
+ Minitest.extensions << 'rails'
+
run_tests
end