From b9f4ea7198aadaeaaf6761316f0d3c96e73e4753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 13 Jul 2009 18:29:40 +0200 Subject: Add hooks for integration and performance tests. --- railties/lib/generators.rb | 2 ++ .../rails/integration_test/integration_test_generator.rb | 6 +----- .../rails/integration_test/templates/integration_test.rb | 10 ---------- .../rails/performance_test/performance_test_generator.rb | 6 +----- .../rails/performance_test/templates/performance_test.rb | 9 --------- .../test_unit/integration/integration_generator.rb | 13 +++++++++++++ .../test_unit/integration/templates/integration_test.rb | 10 ++++++++++ .../test_unit/performance/performance_generator.rb | 13 +++++++++++++ .../test_unit/performance/templates/performance_test.rb | 9 +++++++++ 9 files changed, 49 insertions(+), 29 deletions(-) delete mode 100644 railties/lib/generators/rails/integration_test/templates/integration_test.rb delete mode 100644 railties/lib/generators/rails/performance_test/templates/performance_test.rb create mode 100644 railties/lib/generators/test_unit/integration/integration_generator.rb create mode 100644 railties/lib/generators/test_unit/integration/templates/integration_test.rb create mode 100644 railties/lib/generators/test_unit/performance/performance_generator.rb create mode 100644 railties/lib/generators/test_unit/performance/templates/performance_test.rb (limited to 'railties') diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb index 8fe5dabf86..3cf4ccb79a 100644 --- a/railties/lib/generators.rb +++ b/railties/lib/generators.rb @@ -36,9 +36,11 @@ module Rails :fixture => true, :force_plural => false, :helper => true, + :integration_tool => :test_unit, :layout => true, :migration => true, :orm => :active_record, + :performance_tool => :test_unit, :resource_controller => :controller, :scaffold_controller => :scaffold_controller, :singleton => false, diff --git a/railties/lib/generators/rails/integration_test/integration_test_generator.rb b/railties/lib/generators/rails/integration_test/integration_test_generator.rb index b45ef1597c..363a327fcb 100644 --- a/railties/lib/generators/rails/integration_test/integration_test_generator.rb +++ b/railties/lib/generators/rails/integration_test/integration_test_generator.rb @@ -1,11 +1,7 @@ module Rails module Generators class IntegrationTestGenerator < NamedBase - check_class_collision :suffix => "Test" - - def create_test_files - template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") - end + hook_for :integration_tool, :as => :integration end end end diff --git a/railties/lib/generators/rails/integration_test/templates/integration_test.rb b/railties/lib/generators/rails/integration_test/templates/integration_test.rb deleted file mode 100644 index 2c57158b1c..0000000000 --- a/railties/lib/generators/rails/integration_test/templates/integration_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionController::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/railties/lib/generators/rails/performance_test/performance_test_generator.rb b/railties/lib/generators/rails/performance_test/performance_test_generator.rb index b8efda8df3..d1c71ab8ed 100644 --- a/railties/lib/generators/rails/performance_test/performance_test_generator.rb +++ b/railties/lib/generators/rails/performance_test/performance_test_generator.rb @@ -1,11 +1,7 @@ module Rails module Generators class PerformanceTestGenerator < NamedBase - check_class_collision :suffix => "Test" - - def create_test_files - template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb") - end + hook_for :performance_tool, :as => :performance end end end diff --git a/railties/lib/generators/rails/performance_test/templates/performance_test.rb b/railties/lib/generators/rails/performance_test/templates/performance_test.rb deleted file mode 100644 index 27c91b0fca..0000000000 --- a/railties/lib/generators/rails/performance_test/templates/performance_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'performance_test_help' - -class <%= class_name %>Test < ActionController::PerformanceTest - # Replace this with your real tests. - def test_homepage - get '/' - end -end diff --git a/railties/lib/generators/test_unit/integration/integration_generator.rb b/railties/lib/generators/test_unit/integration/integration_generator.rb new file mode 100644 index 0000000000..d9d9b3bf1d --- /dev/null +++ b/railties/lib/generators/test_unit/integration/integration_generator.rb @@ -0,0 +1,13 @@ +require 'generators/test_unit' + +module TestUnit + module Generators + class IntegrationGenerator < Base + check_class_collision :suffix => "Test" + + def create_test_files + template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") + end + end + end +end diff --git a/railties/lib/generators/test_unit/integration/templates/integration_test.rb b/railties/lib/generators/test_unit/integration/templates/integration_test.rb new file mode 100644 index 0000000000..2c57158b1c --- /dev/null +++ b/railties/lib/generators/test_unit/integration/templates/integration_test.rb @@ -0,0 +1,10 @@ +require 'test_helper' + +class <%= class_name %>Test < ActionController::IntegrationTest + fixtures :all + + # Replace this with your real tests. + test "the truth" do + assert true + end +end diff --git a/railties/lib/generators/test_unit/performance/performance_generator.rb b/railties/lib/generators/test_unit/performance/performance_generator.rb new file mode 100644 index 0000000000..0d9c646b26 --- /dev/null +++ b/railties/lib/generators/test_unit/performance/performance_generator.rb @@ -0,0 +1,13 @@ +require 'generators/test_unit' + +module TestUnit + module Generators + class PerformanceGenerator < Base + check_class_collision :suffix => "Test" + + def create_test_files + template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb") + end + end + end +end diff --git a/railties/lib/generators/test_unit/performance/templates/performance_test.rb b/railties/lib/generators/test_unit/performance/templates/performance_test.rb new file mode 100644 index 0000000000..27c91b0fca --- /dev/null +++ b/railties/lib/generators/test_unit/performance/templates/performance_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' +require 'performance_test_help' + +class <%= class_name %>Test < ActionController::PerformanceTest + # Replace this with your real tests. + def test_homepage + get '/' + end +end -- cgit v1.2.3