aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-02-22 16:14:14 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2016-02-22 16:14:14 -0800
commit7a36686c115f1c6c60ac0a51bc4991c3d32b6e5d (patch)
treed8ec6d272db20d3d3f04457214cdd291c478124f
parent353782652b7dae7573f6480439519f227c41185a (diff)
downloadrails-7a36686c115f1c6c60ac0a51bc4991c3d32b6e5d.tar.gz
rails-7a36686c115f1c6c60ac0a51bc4991c3d32b6e5d.tar.bz2
rails-7a36686c115f1c6c60ac0a51bc4991c3d32b6e5d.zip
make sure `rake test` respects TESTOPTS
We should be able to pass options to minitest via TESTOPTS environment variable
-rw-r--r--railties/lib/rails/test_unit/minitest_plugin.rb3
-rw-r--r--railties/test/application/test_runner_test.rb13
2 files changed, 15 insertions, 1 deletions
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb
index efc8b82d61..f22139490b 100644
--- a/railties/lib/rails/test_unit/minitest_plugin.rb
+++ b/railties/lib/rails/test_unit/minitest_plugin.rb
@@ -1,6 +1,7 @@
require "active_support/core_ext/module/attribute_accessors"
require "rails/test_unit/reporter"
require "rails/test_unit/test_requirer"
+require 'shellwords'
module Minitest
class SuppressedSummaryReporter < SummaryReporter
@@ -60,7 +61,7 @@ module Minitest
# as the patterns would also contain the other Rake tasks.
def self.rake_run(patterns) # :nodoc:
@rake_patterns = patterns
- passed = run
+ passed = run(Shellwords.split(ENV['TESTOPTS'] || ''))
exit passed unless passed
passed
end
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index b0f348f3f1..1e0fbddb58 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -502,6 +502,19 @@ module ApplicationTests
assert_match '1 runs, 1 assertions', output
end
+ def test_rake_passes_TESTOPTS_to_minitest
+ create_test_file :models, 'account'
+ output = Dir.chdir(app_path) { `bin/rake test TESTOPTS=-v` }
+ assert_match "AccountTest#test_truth", output, "passing TEST= should run selected test"
+ end
+
+ def test_rake_passes_multiple_TESTOPTS_to_minitest
+ create_test_file :models, 'account'
+ output = Dir.chdir(app_path) { `bin/rake test TESTOPTS='-v --seed=1234'` }
+ assert_match "AccountTest#test_truth", output, "passing TEST= should run selected test"
+ assert_match "seed=1234", output, "passing TEST= should run selected test"
+ end
+
private
def run_test_command(arguments = 'test/unit/test_test.rb')
Dir.chdir(app_path) { `bin/rails t #{arguments}` }