diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2014-09-15 08:23:14 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2014-09-15 09:43:02 +0900 |
commit | 14f07fdc070c14bc68daa863098d24c561dce49b (patch) | |
tree | 3a2dac229db9eb791805bbb4b9dafd2aeec7ef9e /railties | |
parent | e47b3e15edc8e4688611427768c51b9269d01293 (diff) | |
download | rails-14f07fdc070c14bc68daa863098d24c561dce49b.tar.gz rails-14f07fdc070c14bc68daa863098d24c561dce49b.tar.bz2 rails-14f07fdc070c14bc68daa863098d24c561dce49b.zip |
Add `test:jobs` task
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/test_unit/testing.rake | 6 | ||||
-rw-r--r-- | railties/test/application/test_runner_test.rb | 17 |
2 files changed, 17 insertions, 6 deletions
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 285e2ce846..957deb8a60 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -3,7 +3,7 @@ require 'rails/test_unit/sub_test_task' task default: :test -desc 'Runs test:units, test:functionals, test:generators, test:integration together' +desc 'Runs test:units, test:functionals, test:generators, test:integration, test:jobs together' task :test do Rails::TestTask.test_creator(Rake.application.top_level_tasks).invoke_rake_task end @@ -13,7 +13,7 @@ namespace :test do # Placeholder task for other Railtie and plugins to enhance. See Active Record for an example. end - task :run => ['test:units', 'test:functionals', 'test:generators', 'test:integration'] + task :run => ['test:units', 'test:functionals', 'test:generators', 'test:integration', 'test:jobs'] # Inspired by: http://ngauthier.com/2012/02/quick-tests-with-bash.html desc "Run tests quickly by merging all types and not resetting db" @@ -28,7 +28,7 @@ namespace :test do Rails::TestTask.new(single: "test:prepare") - ["models", "helpers", "controllers", "mailers", "integration"].each do |name| + ["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name| Rails::TestTask.new(name => "test:prepare") do |t| t.pattern = "test/#{name}/**/*_test.rb" end diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 118f22995e..032b11a95f 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -109,6 +109,17 @@ module ApplicationTests end end + def test_run_jobs + create_test_file :jobs, 'foo_job' + create_test_file :jobs, 'bar_job' + create_test_file :models, 'foo' + run_test_jobs_command.tap do |output| + assert_match "FooJobTest", output + assert_match "BarJobTest", output + assert_match "2 runs, 2 assertions, 0 failures", output + end + end + def test_run_functionals create_test_file :mailers, 'foo_mailer' create_test_file :controllers, 'bar_controller' @@ -132,11 +143,11 @@ module ApplicationTests end def test_run_all_suites - suites = [:models, :helpers, :unit, :controllers, :mailers, :functional, :integration] + suites = [:models, :helpers, :unit, :controllers, :mailers, :functional, :integration, :jobs] suites.each { |suite| create_test_file suite, "foo_#{suite}" } run_test_command('') .tap do |output| suites.each { |suite| assert_match "Foo#{suite.to_s.camelize}Test", output } - assert_match "7 runs, 7 assertions, 0 failures", output + assert_match "8 runs, 8 assertions, 0 failures", output end end @@ -245,7 +256,7 @@ module ApplicationTests def run_test_command(arguments = 'test/unit/test_test.rb') run_task ['test', arguments] end - %w{ mailers models helpers units controllers functionals integration }.each do |type| + %w{ mailers models helpers units controllers functionals integration jobs }.each do |type| define_method("run_test_#{type}_command") do run_task ["test:#{type}"] end |