mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added integration and performance test generators.
This commit is contained in:
parent
0f1c325f3c
commit
da1baeab4a
10 changed files with 104 additions and 0 deletions
8
railties/lib/generators/rails/integration_test/USAGE
Normal file
8
railties/lib/generators/rails/integration_test/USAGE
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
8
railties/lib/generators/rails/performance_test/USAGE
Normal file
8
railties/lib/generators/rails/performance_test/USAGE
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
18
railties/test/generators/integration_test_generator_test.rb
Normal file
18
railties/test/generators/integration_test_generator_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'abstract_unit'
|
||||
require 'generators/generators_test_helper'
|
||||
require 'generators/rails/integration_test/integration_test_generator'
|
||||
|
||||
class IntegrationTestGeneratorTest < GeneratorsTestCase
|
||||
|
||||
def test_integration_test_skeleton_is_created
|
||||
run_generator
|
||||
assert_file "test/integration/integration_test.rb"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def run_generator(args=["integration"])
|
||||
silence(:stdout) { Rails::Generators::IntegrationTestGenerator.start args, :root => destination_root }
|
||||
end
|
||||
|
||||
end
|
18
railties/test/generators/performance_test_generator_test.rb
Normal file
18
railties/test/generators/performance_test_generator_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'abstract_unit'
|
||||
require 'generators/generators_test_helper'
|
||||
require 'generators/rails/performance_test/performance_test_generator'
|
||||
|
||||
class PerformanceTestGeneratorTest < GeneratorsTestCase
|
||||
|
||||
def test_performance_test_skeleton_is_created
|
||||
run_generator
|
||||
assert_file "test/performance/performance_test.rb"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def run_generator(args=["performance"])
|
||||
silence(:stdout) { Rails::Generators::PerformanceTestGenerator.start args, :root => destination_root }
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue