aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb6
-rw-r--r--railties/lib/rails/generators/rails/controller/USAGE8
-rw-r--r--railties/lib/rails/generators/rails/helper/USAGE2
-rw-r--r--railties/lib/rails/generators/rails/model/USAGE4
-rw-r--r--railties/lib/rails/generators/rails/observer/USAGE2
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/USAGE8
-rw-r--r--railties/lib/rails/generators/test_unit/controller/controller_generator.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/helper/helper_generator.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/model/model_generator.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/observer/observer_generator.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb2
-rw-r--r--railties/lib/rails/tasks/statistics.rake8
-rw-r--r--railties/lib/rails/test_unit/testing.rake36
14 files changed, 58 insertions, 28 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index b71b16b043..98997864de 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -113,9 +113,11 @@ module Rails
def test
empty_directory_with_keep_file 'test/fixtures'
- empty_directory_with_keep_file 'test/functional'
+ empty_directory_with_keep_file 'test/controllers'
+ empty_directory_with_keep_file 'test/mailers'
+ empty_directory_with_keep_file 'test/models'
+ empty_directory_with_keep_file 'test/helpers'
empty_directory_with_keep_file 'test/integration'
- empty_directory_with_keep_file 'test/unit'
template 'test/performance/browsing_test.rb'
template 'test/test_helper.rb'
diff --git a/railties/lib/rails/generators/rails/controller/USAGE b/railties/lib/rails/generators/rails/controller/USAGE
index b658777b12..9def4af65c 100644
--- a/railties/lib/rails/generators/rails/controller/USAGE
+++ b/railties/lib/rails/generators/rails/controller/USAGE
@@ -12,7 +12,7 @@ Example:
`rails generate controller CreditCards open debit credit close`
CreditCards controller with URLs like /credit_cards/debit.
- Controller: app/controllers/credit_cards_controller.rb
- Functional Test: test/functional/credit_cards_controller_test.rb
- Views: app/views/credit_cards/debit.html.erb [...]
- Helper: app/helpers/credit_cards_helper.rb
+ Controller: app/controllers/credit_cards_controller.rb
+ Test: test/controllers/credit_cards_controller_test.rb
+ Views: app/views/credit_cards/debit.html.erb [...]
+ Helper: app/helpers/credit_cards_helper.rb
diff --git a/railties/lib/rails/generators/rails/helper/USAGE b/railties/lib/rails/generators/rails/helper/USAGE
index c0ddb0f606..30e323a858 100644
--- a/railties/lib/rails/generators/rails/helper/USAGE
+++ b/railties/lib/rails/generators/rails/helper/USAGE
@@ -13,5 +13,5 @@ Example:
Credit card helper.
Helper: app/helpers/credit_card_helper.rb
- Test: test/unit/helpers/credit_card_helper_test.rb
+ Test: test/helpers/credit_card_helper_test.rb
diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE
index c46c86076e..e29e19490e 100644
--- a/railties/lib/rails/generators/rails/model/USAGE
+++ b/railties/lib/rails/generators/rails/model/USAGE
@@ -74,7 +74,7 @@ Examples:
For ActiveRecord and TestUnit it creates:
Model: app/models/account.rb
- Test: test/unit/account_test.rb
+ Test: test/models/account_test.rb
Fixtures: test/fixtures/accounts.yml
Migration: db/migrate/XXX_add_accounts.rb
@@ -88,7 +88,7 @@ Examples:
Module: app/models/admin.rb
Model: app/models/admin/account.rb
- Test: test/unit/admin/account_test.rb
+ Test: test/models/admin/account_test.rb
Fixtures: test/fixtures/admin/accounts.yml
Migration: db/migrate/XXX_add_admin_accounts.rb
diff --git a/railties/lib/rails/generators/rails/observer/USAGE b/railties/lib/rails/generators/rails/observer/USAGE
index d8f32a6a48..177ff49e4a 100644
--- a/railties/lib/rails/generators/rails/observer/USAGE
+++ b/railties/lib/rails/generators/rails/observer/USAGE
@@ -9,4 +9,4 @@ Example:
For ActiveRecord and TestUnit it creates:
Observer: app/models/account_observer.rb
- TestUnit: test/unit/account_observer_test.rb
+ TestUnit: test/models/account_observer_test.rb
diff --git a/railties/lib/rails/generators/rails/scaffold_controller/USAGE b/railties/lib/rails/generators/rails/scaffold_controller/USAGE
index 5cd51b62d4..8ba4c5ccbc 100644
--- a/railties/lib/rails/generators/rails/scaffold_controller/USAGE
+++ b/railties/lib/rails/generators/rails/scaffold_controller/USAGE
@@ -13,7 +13,7 @@ Example:
`rails generate scaffold_controller CreditCard`
Credit card controller with URLs like /credit_card/debit.
- Controller: app/controllers/credit_cards_controller.rb
- Functional Test: test/functional/credit_cards_controller_test.rb
- Views: app/views/credit_cards/index.html.erb [...]
- Helper: app/helpers/credit_cards_helper.rb
+ Controller: app/controllers/credit_cards_controller.rb
+ Test: test/controllers/credit_cards_controller_test.rb
+ Views: app/views/credit_cards/index.html.erb [...]
+ Helper: app/helpers/credit_cards_helper.rb
diff --git a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb
index 20f3bd8965..db99e55e9e 100644
--- a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb
+++ b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb
@@ -8,7 +8,7 @@ module TestUnit
def create_test_files
template 'functional_test.rb',
- File.join('test/functional', class_path, "#{file_name}_controller_test.rb")
+ File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb
index 4ea80bf7be..d4c287540c 100644
--- a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb
+++ b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb
@@ -6,7 +6,7 @@ module TestUnit
check_class_collision :suffix => "HelperTest"
def create_helper_files
- template 'helper_test.rb', File.join('test/unit/helpers', class_path, "#{file_name}_helper_test.rb")
+ template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
index 1a49286d41..a404a13bd2 100644
--- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
+++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
@@ -7,7 +7,7 @@ module TestUnit
check_class_collision :suffix => "Test"
def create_test_files
- template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb")
+ template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/model/model_generator.rb b/railties/lib/rails/generators/test_unit/model/model_generator.rb
index c1dd535dd3..ffb51e437d 100644
--- a/railties/lib/rails/generators/test_unit/model/model_generator.rb
+++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb
@@ -9,7 +9,7 @@ module TestUnit
check_class_collision :suffix => "Test"
def create_test_file
- template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
+ template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
end
hook_for :fixture_replacement
diff --git a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb
index 6cc1158c21..658373d554 100644
--- a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb
+++ b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb
@@ -6,7 +6,7 @@ module TestUnit
check_class_collision :suffix => "ObserverTest"
def create_test_files
- template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
+ template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_observer_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
index ca7fee3b6e..e9de51ba72 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -12,7 +12,7 @@ module TestUnit
def create_test_files
template "functional_test.rb",
- File.join("test/functional", controller_class_path, "#{controller_file_name}_controller_test.rb")
+ File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
end
private
diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake
index 67a6d2d2ac..c1674c72ad 100644
--- a/railties/lib/rails/tasks/statistics.rake
+++ b/railties/lib/rails/tasks/statistics.rake
@@ -6,9 +6,13 @@ STATS_DIRECTORIES = [
%w(Javascripts app/assets/javascripts),
%w(Libraries lib/),
%w(APIs app/apis),
+ %w(Controller\ tests test/controllers),
+ %w(Helper\ tests test/helpers),
+ %w(Model\ tests test/models),
+ %w(Mailer\ tests test/mailers),
%w(Integration\ tests test/integration),
- %w(Functional\ tests test/functional),
- %w(Unit\ tests test/unit)
+ %w(Functional\ tests\ (old) test/functional),
+ %w(Unit\ tests \ (old) test/unit)
].collect { |name, dir| [ name, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
desc "Report code statistics (KLOCs, etc) from the application"
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake
index 0de4afe905..63cb955d44 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -15,11 +15,11 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
# Support subdirs in app/models and app/controllers
modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
- # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
+ # For modified files in app/ run the tests for it. ex. /test/controllers/account_controller.rb
test = "#{modified_test_path}/#{source_file}_test.rb"
tests.push test if File.exist?(test)
- # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
+ # For modified files in app, run tests in subdirs too. ex. /test/controllers/account/*_test.rb
test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
@@ -74,7 +74,9 @@ namespace :test do
Rake::TestTask.new(:recent => "test:prepare") do |t|
since = TEST_CHANGES_SINCE
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
+ recent_tests('app/models/**/*.rb', 'test/models', since) +
recent_tests('app/models/**/*.rb', 'test/unit', since) +
+ recent_tests('app/controllers/**/*.rb', 'test/controllers', since) +
recent_tests('app/controllers/**/*.rb', 'test/functional', since)
t.libs << 'test'
@@ -95,8 +97,10 @@ namespace :test do
models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
- unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
- functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
+ unit_tests = models.map { |model| "test/models/#{File.basename(model, '.rb')}_test.rb" } +
+ models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } +
+ functional_tests = controllers.map { |controller| "test/controllers/#{File.basename(controller, '.rb')}_test.rb" } +
+ controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
(unit_tests + functional_tests).uniq.select { |file| File.exist?(file) }
end
@@ -108,14 +112,34 @@ namespace :test do
t.libs << "test"
end
+ Rails::SubTestTask.new(:models => "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/models/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(:helpers => "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/helpers/**/*_test.rb'
+ end
+
Rails::SubTestTask.new(:units => "test:prepare") do |t|
t.libs << "test"
- t.pattern = 'test/unit/**/*_test.rb'
+ t.pattern = 'test/{models,helpers,unit}/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(:controllers => "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/controllers/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(:mailers => "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/mailers/**/*_test.rb'
end
Rails::SubTestTask.new(:functionals => "test:prepare") do |t|
t.libs << "test"
- t.pattern = 'test/functional/**/*_test.rb'
+ t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb'
end
Rails::SubTestTask.new(:integration => "test:prepare") do |t|