diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-09-25 20:57:50 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-09-25 20:57:50 +0200 |
commit | b724dbbb8b337d84a3ca8380c9dd75d79a44badf (patch) | |
tree | 2144e3d618a35c79f529d1491040670e647074d3 | |
parent | 0dfc467587a797ce9eb44cbe4f496b86f3462e79 (diff) | |
download | rails-b724dbbb8b337d84a3ca8380c9dd75d79a44badf.tar.gz rails-b724dbbb8b337d84a3ca8380c9dd75d79a44badf.tar.bz2 rails-b724dbbb8b337d84a3ca8380c9dd75d79a44badf.zip |
Use autorun when running via Rake.
Makes sure we get support for `Minitest.after_run` hooks and don't
accidentally run tests twice.
Requires overriding minitest `run` to respect the TESTOPTS variable.
-rw-r--r-- | railties/lib/rails/test_unit/minitest_plugin.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb index 0544847293..6e196a32ab 100644 --- a/railties/lib/rails/test_unit/minitest_plugin.rb +++ b/railties/lib/rails/test_unit/minitest_plugin.rb @@ -61,11 +61,21 @@ module Minitest # as the patterns would also contain the other Rake tasks. def self.rake_run(patterns) # :nodoc: @rake_patterns = patterns - passed = run(Shellwords.split(ENV["TESTOPTS"] || "")) - exit passed unless passed - passed + autorun end + module RunRespectingRakeTestopts + def run(args = []) + if defined?(@rake_patterns) + args = Shellwords.split(ENV["TESTOPTS"] || "") + end + + super + end + end + + singleton_class.prepend RunRespectingRakeTestopts + # Owes great inspiration to test runner trailblazers like RSpec, # minitest-reporters, maxitest and others. def self.plugin_rails_init(options) |