diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-26 09:11:37 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-26 11:59:13 +0200 |
commit | da1baeab4a681b63b29f4a3c7222d660306551d9 (patch) | |
tree | fce6174ff8c231a957095a46eb383ba28384fa1b /railties/lib/generators | |
parent | 0f1c325f3cd8bfbedc0a6e4925122016288e2817 (diff) | |
download | rails-da1baeab4a681b63b29f4a3c7222d660306551d9.tar.gz rails-da1baeab4a681b63b29f4a3c7222d660306551d9.tar.bz2 rails-da1baeab4a681b63b29f4a3c7222d660306551d9.zip |
Added integration and performance test generators.
Diffstat (limited to 'railties/lib/generators')
8 files changed, 68 insertions, 0 deletions
diff --git a/railties/lib/generators/rails/integration_test/USAGE b/railties/lib/generators/rails/integration_test/USAGE new file mode 100644 index 0000000000..09e2691f69 --- /dev/null +++ b/railties/lib/generators/rails/integration_test/USAGE @@ -0,0 +1,8 @@ +Description: + Stubs out a new integration test. Pass the name of the test, either + CamelCased or under_scored, as an argument. The new test class is + generated in test/integration/testname_test.rb + +Example: + `./script/generate integration_test GeneralStories` creates a GeneralStories + integration test in test/integration/general_stories_test.rb diff --git a/railties/lib/generators/rails/integration_test/integration_test_generator.rb b/railties/lib/generators/rails/integration_test/integration_test_generator.rb new file mode 100644 index 0000000000..a958350019 --- /dev/null +++ b/railties/lib/generators/rails/integration_test/integration_test_generator.rb @@ -0,0 +1,13 @@ +module Rails + module Generators + class IntegrationTestGenerator < NamedBase + def check_class_collisions + class_collisions class_name, "#{class_name}Test" + end + + 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/rails/integration_test/templates/integration_test.rb b/railties/lib/generators/rails/integration_test/templates/integration_test.rb new file mode 100644 index 0000000000..2c57158b1c --- /dev/null +++ b/railties/lib/generators/rails/integration_test/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/rails/performance_test/USAGE b/railties/lib/generators/rails/performance_test/USAGE new file mode 100644 index 0000000000..d84051eb02 --- /dev/null +++ b/railties/lib/generators/rails/performance_test/USAGE @@ -0,0 +1,8 @@ +Description: + Stubs out a new performance test. Pass the name of the test, either + CamelCased or under_scored, as an argument. The new test class is + generated in test/performance/testname_test.rb + +Example: + `./script/generate performance_test GeneralStories` creates a GeneralStories + performance test in test/performance/general_stories_test.rb diff --git a/railties/lib/generators/rails/performance_test/performance_test_generator.rb b/railties/lib/generators/rails/performance_test/performance_test_generator.rb new file mode 100644 index 0000000000..8e2537c2b3 --- /dev/null +++ b/railties/lib/generators/rails/performance_test/performance_test_generator.rb @@ -0,0 +1,12 @@ +module Rails + module Generators + class PerformanceTestGenerator < NamedBase
+ def check_class_collisions + class_collisions class_name, "#{class_name}Test" + end + + 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/rails/performance_test/templates/performance_test.rb b/railties/lib/generators/rails/performance_test/templates/performance_test.rb new file mode 100644 index 0000000000..27c91b0fca --- /dev/null +++ b/railties/lib/generators/rails/performance_test/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 diff --git a/railties/lib/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/generators/test_unit/mailer/mailer_generator.rb index 84e3024427..9249e9bd51 100644 --- a/railties/lib/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/generators/test_unit/mailer/mailer_generator.rb @@ -3,6 +3,10 @@ module TestUnit class MailerGenerator < Base argument :actions, :type => :array, :default => [], :banner => "method method" + def check_class_collisions + class_collisions class_name, "#{class_name}Test" + end + def create_test_files template "unit_test.rb", File.join('test', 'unit', class_path, "#{file_name}_test.rb") end diff --git a/railties/lib/generators/test_unit/observer/observer_generator.rb b/railties/lib/generators/test_unit/observer/observer_generator.rb index adfd90a086..f4534840f3 100644 --- a/railties/lib/generators/test_unit/observer/observer_generator.rb +++ b/railties/lib/generators/test_unit/observer/observer_generator.rb @@ -1,6 +1,10 @@ module TestUnit module Generators class ObserverGenerator < Base + def check_class_collisions + class_collisions class_name, "#{class_name}Test" + end + def create_test_files template 'unit_test.rb', File.join('test', 'unit', class_path, "#{file_name}_observer_test.rb") end |