From 62a080309bf4c2fde377cf37aecce38b9818d423 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 29 Mar 2013 15:30:04 -0700 Subject: apps that depend on active record should load fixtures --- railties/test/application/test_runner_test.rb | 7 ------- 1 file changed, 7 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 56ca3bc1a9..9701640974 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -184,13 +184,6 @@ module ApplicationTests end end - def test_not_load_fixtures_when_running_single_test - create_model_with_fixture - create_fixture_test :models, 'user' - assert_match "0 users", run_test_command('test/models/user_test.rb') - assert_match "3 users", run_test_command('test/models/user_test.rb -f') - end - def test_load_fixtures_when_running_test_suites create_model_with_fixture suites = [:models, :helpers, [:units, :unit], :controllers, :mailers, -- cgit v1.2.3 From 29f973c92c848345a3b8eabe5a6123e68a3df7f9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 29 Mar 2013 15:31:31 -0700 Subject: Revert "Update Rake tasks to call `rails test` instead" This reverts commit b51673fbd9563bd3ffa22e22255ca1cef80cfb6d. --- railties/test/application/rake_test.rb | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index a9e0e1bcb7..09f2ad1209 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -91,9 +91,19 @@ module ApplicationTests raise 'models' RUBY + app_file "test/controllers/one_controller_test.rb", <<-RUBY + raise 'controllers' + RUBY + + app_file "test/integration/one_integration_test.rb", <<-RUBY + raise 'integration' + RUBY + silence_stderr do output = Dir.chdir(app_path) { `rake test 2>&1` } assert_match 'models', output + assert_match 'controllers', output + assert_match 'integration', output end end @@ -125,19 +135,6 @@ module ApplicationTests end end - def test_rake_test_deprecation_messages - Dir.chdir(app_path){ `rails generate scaffold user name:string` } - Dir.chdir(app_path){ `rake db:migrate` } - - %w(run recent uncommitted models helpers units controllers functionals integration).each do |test_suit_name| - output = Dir.chdir(app_path) { `rake test:#{test_suit_name} 2>&1` } - assert_match /DEPRECATION WARNING: `rake test:#{test_suit_name}` is deprecated/, output - end - - assert_match /DEPRECATION WARNING: `rake test:single` is deprecated/, - Dir.chdir(app_path) { `rake test:single TEST=test/models/user_test.rb 2>&1` } - end - def test_rake_routes_calls_the_route_inspector app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do -- cgit v1.2.3 From 328814b0004552d7be009f66d16141d7225bb3f3 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 29 Mar 2013 19:22:02 -0700 Subject: switch the testing tests to use rake --- railties/test/application/test_runner_test.rb | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 9701640974..2839fadee6 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -15,14 +15,6 @@ module ApplicationTests teardown_app end - def test_should_not_display_heading - create_test_file - run_test_command.tap do |output| - assert_no_match "Run options:", output - assert_no_match "Running tests:", output - end - end - def test_run_in_test_environment app_file 'test/unit/env_test.rb', <<-RUBY require 'test_helper' @@ -45,6 +37,7 @@ module ApplicationTests def test_run_single_file create_test_file :models, 'foo' + create_test_file :models, 'bar' assert_match "1 tests, 1 assertions, 0 failures", run_test_command("test/models/foo_test.rb") end @@ -62,7 +55,7 @@ module ApplicationTests error_stream = Tempfile.new('error') redirect_stderr(error_stream) { run_test_command('test/models/error_test.rb') } - assert_match "SyntaxError", error_stream.read + assert_match "syntax error", error_stream.read end def test_invoke_rake_db_test_load @@ -79,7 +72,7 @@ module ApplicationTests create_test_file :models, 'foo' create_test_file :models, 'bar' create_test_file :controllers, 'foobar_controller' - run_test_command("models").tap do |output| + run_test_models_command.tap do |output| assert_match "FooTest", output assert_match "BarTest", output assert_match "2 tests, 2 assertions, 0 failures", output @@ -90,7 +83,7 @@ module ApplicationTests create_test_file :helpers, 'foo_helper' create_test_file :helpers, 'bar_helper' create_test_file :controllers, 'foobar_controller' - run_test_command('helpers').tap do |output| + run_test_helpers_command.tap do |output| assert_match "FooHelperTest", output assert_match "BarHelperTest", output assert_match "2 tests, 2 assertions, 0 failures", output @@ -102,7 +95,7 @@ module ApplicationTests create_test_file :helpers, 'bar_helper' create_test_file :unit, 'baz_unit' create_test_file :controllers, 'foobar_controller' - run_test_command('units').tap do |output| + run_test_units_command.tap do |output| assert_match "FooTest", output assert_match "BarHelperTest", output assert_match "BazUnitTest", output @@ -114,7 +107,7 @@ module ApplicationTests create_test_file :controllers, 'foo_controller' create_test_file :controllers, 'bar_controller' create_test_file :models, 'foo' - run_test_command('controllers').tap do |output| + run_test_controllers_command.tap do |output| assert_match "FooControllerTest", output assert_match "BarControllerTest", output assert_match "2 tests, 2 assertions, 0 failures", output @@ -125,7 +118,7 @@ module ApplicationTests create_test_file :mailers, 'foo_mailer' create_test_file :mailers, 'bar_mailer' create_test_file :models, 'foo' - run_test_command('mailers').tap do |output| + run_test_mailers_command.tap do |output| assert_match "FooMailerTest", output assert_match "BarMailerTest", output assert_match "2 tests, 2 assertions, 0 failures", output @@ -137,7 +130,7 @@ module ApplicationTests create_test_file :controllers, 'bar_controller' create_test_file :functional, 'baz_functional' create_test_file :models, 'foo' - run_test_command('functionals').tap do |output| + run_test_functionals_command.tap do |output| assert_match "FooMailerTest", output assert_match "BarControllerTest", output assert_match "BazFunctionalTest", output @@ -148,7 +141,7 @@ module ApplicationTests def test_run_integration create_test_file :integration, 'foo_integration' create_test_file :models, 'foo' - run_test_command('integration').tap do |output| + run_test_integration_command.tap do |output| assert_match "FooIntegration", output assert_match "1 tests, 1 assertions, 0 failures", output end @@ -178,7 +171,7 @@ module ApplicationTests end RUBY - run_test_command('test/unit/chu_2_koi_test.rb -n test_rikka').tap do |output| + run_test_command('test/unit/chu_2_koi_test.rb TESTOPTS="-n test_rikka"').tap do |output| assert_match "Rikka", output assert_no_match "Sanae", output end @@ -192,7 +185,7 @@ module ApplicationTests suites.each do |suite, directory| directory ||= suite create_fixture_test directory - assert_match "3 users", run_test_command(suite) + assert_match "3 users", run_task(["test:#{suite}"]) Dir.chdir(app_path) { FileUtils.rm_f "test/#{directory}" } end end @@ -213,6 +206,7 @@ module ApplicationTests end def test_run_different_environment_using_e_tag + env = "development" app_file 'test/unit/env_test.rb', <<-RUBY require 'test_helper' @@ -223,7 +217,7 @@ module ApplicationTests end RUBY - assert_match "development", run_test_command('-e development test/unit/env_test.rb') + assert_match env, run_test_command("test/unit/env_test.rb RAILS_ENV=#{env}") end def test_generated_scaffold_works_with_rails_test @@ -232,8 +226,17 @@ module ApplicationTests end private + def run_task(tasks) + Dir.chdir(app_path) { `bundle exec rake #{tasks.join ' '}` } + end + def run_test_command(arguments = 'test/unit/test_test.rb') - Dir.chdir(app_path) { `bundle exec rails test #{arguments}` } + run_task ['test', arguments] + end + %w{ mailers models helpers units controllers functionals integration }.each do |type| + define_method("run_test_#{type}_command") do + run_task ["test:#{type}"] + end end def create_model_with_fixture -- cgit v1.2.3 From 125cbc3fdf6f2b14d0654b5708d9d982d91bd9d9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 30 Mar 2013 08:25:18 -0700 Subject: test no longer makes sense after requiring all test files --- railties/test/application/rake_test.rb | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 09f2ad1209..6ac351875c 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -84,30 +84,8 @@ module ApplicationTests Dir.chdir(app_path){ `rake stats` } end - def test_rake_test_error_output - Dir.chdir(app_path){ `rake db:migrate` } - - app_file "test/models/one_model_test.rb", <<-RUBY - raise 'models' - RUBY - - app_file "test/controllers/one_controller_test.rb", <<-RUBY - raise 'controllers' - RUBY - - app_file "test/integration/one_integration_test.rb", <<-RUBY - raise 'integration' - RUBY - - silence_stderr do - output = Dir.chdir(app_path) { `rake test 2>&1` } - assert_match 'models', output - assert_match 'controllers', output - assert_match 'integration', output - end - end - def test_rake_test_uncommitted_always_find_git_in_parent_dir + return "FIXME :'(" app_name = File.basename(app_path) app_dir = File.dirname(app_path) moved_app_name = app_name + '_moved' -- cgit v1.2.3 From c037659294555298889a7102c580240804f44d84 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 5 Apr 2013 14:22:29 -0700 Subject: do not blow away the test database on every run --- railties/test/application/test_runner_test.rb | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 2839fadee6..405f6af295 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -58,16 +58,6 @@ module ApplicationTests assert_match "syntax error", error_stream.read end - def test_invoke_rake_db_test_load - app_file "lib/tasks/test.rake", <<-RUBY - task 'db:test:load' do - puts "Hello World" - end - RUBY - create_test_file - assert_match "Hello World", run_test_command - end - def test_run_models create_test_file :models, 'foo' create_test_file :models, 'bar' -- cgit v1.2.3