diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-05 16:38:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-05 16:38:37 -0700 |
commit | 88cf64a6690e3c7cc05bd644bd5ad9a000192ebd (patch) | |
tree | 429feb9ee5a4631834dbcdcddc0cc6c71638757f /railties | |
parent | 7f698da8878b141c5324b2419d73570f507ef08f (diff) | |
download | rails-88cf64a6690e3c7cc05bd644bd5ad9a000192ebd.tar.gz rails-88cf64a6690e3c7cc05bd644bd5ad9a000192ebd.tar.bz2 rails-88cf64a6690e3c7cc05bd644bd5ad9a000192ebd.zip |
extract test info from the command line and set up the test task
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/test_unit/testing.rake | 10 | ||||
-rw-r--r-- | railties/test/application/test_runner_test.rb | 23 |
2 files changed, 28 insertions, 5 deletions
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index bef819a8a8..9a3094b1b7 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -48,12 +48,14 @@ task default: :test desc 'Runs test:units, test:functionals, test:integration together' task :test do - tasks = Rake.application.top_level_tasks - test_files = tasks.grep(/^test\//) - if test_files.any? + info = Rails::TestTask.test_info Rake.application.top_level_tasks + if info.files.any? Rails::TestTask.new('test:single') { |t| - t.test_files = test_files + t.test_files = info.files } + ENV['TESTOPTS'] ||= info.opts + Rake.application.top_level_tasks.replace info.tasks + Rake::Task['test:single'].invoke else Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 180fc315d1..c82ac8b5d3 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -155,7 +155,28 @@ module ApplicationTests end RUBY - run_test_command('test/unit/chu_2_koi_test.rb TESTOPTS="-n test_rikka"').tap do |output| + run_test_command('test/unit/chu_2_koi_test.rb test_rikka').tap do |output| + assert_match "Rikka", output + assert_no_match "Sanae", output + end + end + + def test_run_matched_test + app_file 'test/unit/chu_2_koi_test.rb', <<-RUBY + require 'test_helper' + + class Chu2KoiTest < ActiveSupport::TestCase + def test_rikka + puts 'Rikka' + end + + def test_sanae + puts 'Sanae' + end + end + RUBY + + run_test_command('test/unit/chu_2_koi_test.rb /rikka/').tap do |output| assert_match "Rikka", output assert_no_match "Sanae", output end |