Skip to content
Browse files

Revert "Reorganized app/test directory. [#3057 state:resolved]"

This reverts commit a0dc675.
  • Loading branch information...
1 parent 94ced08 commit 9a865ee25ea01c68015b46e69ca0589f0024a0d5 @josevalim josevalim committed Mar 29, 2010
Showing with 50 additions and 103 deletions.
  1. +0 −2 railties/CHANGELOG
  2. 0 railties/lib/rails/generators/rails/app/templates/test/{models → functional}/.empty_directory
  3. 0 railties/lib/rails/generators/rails/app/templates/test/{helpers → integration}/.empty_directory
  4. 0 railties/lib/rails/generators/rails/app/templates/test/{controllers → unit}/.empty_directory
  5. +1 −1 railties/lib/rails/generators/test_unit/controller/controller_generator.rb
  6. +1 −1 railties/lib/rails/generators/test_unit/helper/helper_generator.rb
  7. +1 −1 railties/lib/rails/generators/test_unit/integration/integration_generator.rb
  8. +1 −1 railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
  9. 0 railties/lib/rails/generators/test_unit/mailer/templates/{controller_test.rb → functional_test.rb}
  10. +1 −1 railties/lib/rails/generators/test_unit/model/model_generator.rb
  11. +1 −1 railties/lib/rails/generators/test_unit/observer/observer_generator.rb
  12. +1 −1 railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
  13. +1 −46 railties/lib/rails/tasks/framework.rake
  14. +15 −21 railties/lib/rails/test_unit/testing.rake
  15. +3 −3 railties/test/generators/app_generator_test.rb
  16. +4 −4 railties/test/generators/controller_generator_test.rb
  17. +1 −1 railties/test/generators/helper_generator_test.rb
  18. +1 −1 railties/test/generators/integration_test_generator_test.rb
  19. +1 −1 railties/test/generators/mailer_generator_test.rb
  20. +1 −1 railties/test/generators/model_generator_test.rb
  21. +1 −1 railties/test/generators/observer_generator_test.rb
  22. +5 −5 railties/test/generators/resource_generator_test.rb
  23. +4 −4 railties/test/generators/scaffold_controller_generator_test.rb
  24. +6 −6 railties/test/generators/scaffold_generator_test.rb
View
2 railties/CHANGELOG
@@ -1,7 +1,5 @@
*Edge*
-* Reorganized app/test directory. Run rake update:test_directory to reorganize your apps [Rizwan Reza]
-
* Added "rake about" as a replacement for script/about [DHH]
* Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example:
View
0 ...pp/templates/test/models/.empty_directory → ...emplates/test/functional/.empty_directory
File renamed without changes.
View
0 ...p/templates/test/helpers/.empty_directory → ...mplates/test/integration/.empty_directory
File renamed without changes.
View
0 ...mplates/test/controllers/.empty_directory → .../app/templates/test/unit/.empty_directory
File renamed without changes.
View
2 railties/lib/rails/generators/test_unit/controller/controller_generator.rb
@@ -8,7 +8,7 @@ class ControllerGenerator < Base
def create_test_files
template 'functional_test.rb',
- File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
+ File.join('test/functional', class_path, "#{file_name}_controller_test.rb")
end
end
end
View
2 railties/lib/rails/generators/test_unit/helper/helper_generator.rb
@@ -6,7 +6,7 @@ class HelperGenerator < Base
check_class_collision :suffix => "HelperTest"
def create_helper_files
- template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb")
+ template 'helper_test.rb', File.join('test/unit/helpers', class_path, "#{file_name}_helper_test.rb")
end
end
end
View
2 railties/lib/rails/generators/test_unit/integration/integration_generator.rb
@@ -6,7 +6,7 @@ class IntegrationGenerator < Base
check_class_collision :suffix => "Test"
def create_test_files
- template 'integration_test.rb', File.join('test/controllers', class_path, "#{file_name}_test.rb")
+ template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
end
end
end
View
2 railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
@@ -7,7 +7,7 @@ class MailerGenerator < Base
check_class_collision :suffix => "Test"
def create_test_files
- template "controller_test.rb", File.join('test/controllers', class_path, "#{file_name}_test.rb")
+ template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb")
end
end
end
View
0 ..._unit/mailer/templates/controller_test.rb → ..._unit/mailer/templates/functional_test.rb
File renamed without changes.
View
2 railties/lib/rails/generators/test_unit/model/model_generator.rb
@@ -9,7 +9,7 @@ class ModelGenerator < Base
check_class_collision :suffix => "Test"
def create_test_file
- template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
+ template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
end
hook_for :fixture_replacement
View
2 railties/lib/rails/generators/test_unit/observer/observer_generator.rb
@@ -6,7 +6,7 @@ class ObserverGenerator < Base
check_class_collision :suffix => "ObserverTest"
def create_test_files
- template 'unit_test.rb', File.join('test/observers', class_path, "#{file_name}_observer_test.rb")
+ template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
end
end
end
View
2 railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -11,7 +11,7 @@ class ScaffoldGenerator < Base
def create_test_files
template 'functional_test.rb',
- File.join('test/controllers', controller_class_path, "#{controller_file_name}_controller_test.rb")
+ File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")
end
end
end
View
47 railties/lib/rails/tasks/framework.rake
@@ -17,7 +17,7 @@ namespace :rails do
end
desc "Update both configs, scripts and public/javascripts from Rails"
- task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller", "update:test_directory" ]
+ task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller" ]
desc "Applies the template supplied by LOCATION=/path/to/template"
task :template do
@@ -72,50 +72,5 @@ namespace :rails do
puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
end
end
-
- desc "Move test directories to new locations"
- task :test_directory do
- if File.exists?(Rails.root.join('test'))
- FileUtils.mkdir(Rails.root.join('test/controllers')) unless File.exists?(Rails.root.join('test/controllers'))
- [Rails.root.join('test/functional'), Rails.root.join('test/integration')].each do |controller_test_dir|
- if File.exists?(controller_test_dir)
- puts "#{controller_test_dir} exists"
- FileUtils.mv(Dir["#{controller_test_dir}/**/*"], Rails.root.join('test/controllers'), :force => true)
- FileUtils.rm_rf(controller_test_dir)
- end
- end
-
- if File.exists?(Rails.root.join('test/unit/helpers'))
- FileUtils.mkdir(Rails.root.join('test/helpers')) unless File.exists?(Rails.root.join('test/helpers'))
- FileUtils.mv(Dir[Rails.root.join('test/unit/helpers/**/*')], Rails.root.join('test/helpers'), :force => true)
- else
- unless File.exists?(Rails.root.join('test/helpers'))
- FileUtils.mkdir(Rails.root.join('test/helpers'))
- end
- end
-
- if File.exists?(Rails.root.join('test/unit'))
- observer_tests = "#{Rails.root}/test/unit/**/*_observer_test.rb"
- unless observer_tests.empty?
- FileUtils.mkdir(Rails.root.join('test/observers')) unless File.exists?(Rails.root.join('test/observers'))
- FileUtils.mv(observer_tests, Rails.root.join('test/observers'), :force => true)
- end
- FileUtils.mkdir(Rails.root.join('test/models')) unless File.exists?(Rails.root.join('test/models'))
- FileUtils.mv(Dir[Rails.root.join('test/unit/*')], Rails.root.join('test/models'), :force => true)
- FileUtils.rm_rf(Rails.root.join('test/unit'))
- end
- end
-
- puts <<-TEST
-
- All test directories have been updated:
-
- test/functional -> test/controllers
- test/functional -> test/controllers
- test/unit/helpers -> test/helpers
- test/unit/**/*_observer_test.rb -> test/observers
- test/unit -> test/models
- TEST
- end
end
end
View
36 railties/lib/rails/test_unit/testing.rake
@@ -40,7 +40,7 @@ end
desc 'Run all unit, functional and integration tests'
task :test do
- errors = %w(test:models test:controllers test:helpers).collect do |task|
+ errors = %w(test:units test:functionals test:integration).collect do |task|
begin
Rake::Task[task].invoke
nil
@@ -55,10 +55,8 @@ namespace :test do
Rake::TestTask.new(:recent => "db: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/**/*_observer.rb', 'test/observers', since) +
- recent_tests('app/controllers/**/*.rb', 'test/controllers', since) +
- recent_tests('app/helpers/**/*.rb', 'test/helpers', since)
+ recent_tests('app/models/**/*.rb', 'test/unit', since) +
+ recent_tests('app/controllers/**/*.rb', 'test/functional', since)
t.libs << 'test'
t.test_files = touched.uniq
@@ -76,39 +74,35 @@ namespace :test do
end
models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
- observers = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*_observer\.rb$/ }
controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
- helpers = changed_since_checkin.select { |path| path =~ /app[\\\/]helpers[\\\/].*\.rb$/ }
- model_tests = models.map { |model| "test/models/#{File.basename(model, '.rb')}_test.rb" }
- observer_tests = observers.map { |observer| "test/observers/#{File.basename(observer, '.rb')}_test.rb" }
- controller_tests = controllers.map { |controller| "test/controllers/#{File.basename(controller, '.rb')}_test.rb" }
- helper_tests = helpers.map { |helper| "test/helpers/#{File.basename(helper, '.rb')}_test.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" }
- (model_tests + observer_tests + controller_tests + helper_tests).uniq
+ unit_tests.uniq + functional_tests.uniq
end
t.libs << 'test'
end
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
- Rake::TestTask.new(:models => "db:test:prepare") do |t|
+ Rake::TestTask.new(:units => "db:test:prepare") do |t|
t.libs << "test"
- t.pattern = ['test/models/**/*_test.rb', 'test/observers/**/*_test.rb']
+ t.pattern = 'test/unit/**/*_test.rb'
end
- Rake::Task['test:models'].comment = "Run the unit tests in test/models and test/observers"
+ Rake::Task['test:units'].comment = "Run the unit tests in test/unit"
- Rake::TestTask.new(:controllers => "db:test:prepare") do |t|
+ Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
t.libs << "test"
- t.pattern = 'test/controllers/**/*_test.rb'
+ t.pattern = 'test/functional/**/*_test.rb'
end
- Rake::Task['test:controllers'].comment = "Run the functional and integration tests in test/controllers"
+ Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional"
- Rake::TestTask.new(:helpers => "db:test:prepare") do |t|
+ Rake::TestTask.new(:integration => "db:test:prepare") do |t|
t.libs << "test"
- t.pattern = 'test/helpers/**/*_test.rb'
+ t.pattern = 'test/integration/**/*_test.rb'
end
- Rake::Task['test:helpers'].comment = "Run the unit tests in test/helpers"
+ Rake::Task['test:integration'].comment = "Run the integration tests in test/integration"
Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t|
t.libs << 'test'
View
6 railties/test/generators/app_generator_test.rb
@@ -37,11 +37,11 @@ def test_application_skeleton_is_created
public/javascripts
public/stylesheets
script/rails
- test/controllers
test/fixtures
- test/helpers
- test/models
+ test/functional
+ test/integration
test/performance
+ test/unit
vendor
vendor/plugins
tmp/sessions
View
8 railties/test/generators/controller_generator_test.rb
@@ -28,23 +28,23 @@ def test_check_class_collision
def test_invokes_helper
run_generator
assert_file "app/helpers/account_helper.rb"
- assert_file "test/helpers/account_helper_test.rb"
+ assert_file "test/unit/helpers/account_helper_test.rb"
end
def test_does_not_invoke_helper_if_required
run_generator ["account", "--skip-helper"]
assert_no_file "app/helpers/account_helper.rb"
- assert_no_file "test/helpers/account_helper_test.rb"
+ assert_no_file "test/unit/helpers/account_helper_test.rb"
end
def test_invokes_default_test_framework
run_generator
- assert_file "test/controllers/account_controller_test.rb"
+ assert_file "test/functional/account_controller_test.rb"
end
def test_does_not_invoke_test_framework_if_required
run_generator ["account", "--no-test-framework"]
- assert_no_file "test/controllers/account_controller_test.rb"
+ assert_no_file "test/functional/account_controller_test.rb"
end
def test_invokes_default_template_engine
View
2 railties/test/generators/helper_generator_test.rb
@@ -15,7 +15,7 @@ def test_helper_skeleton_is_created
def test_invokes_default_test_framework
run_generator
- assert_file "test/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/
+ assert_file "test/unit/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/
end
def test_logs_if_the_test_framework_cannot_be_found
View
2 railties/test/generators/integration_test_generator_test.rb
@@ -7,6 +7,6 @@ class IntegrationTestGeneratorTest < Rails::Generators::TestCase
def test_integration_test_skeleton_is_created
run_generator
- assert_file "test/controllers/integration_test.rb", /class IntegrationTest < ActionController::IntegrationTest/
+ assert_file "test/integration/integration_test.rb", /class IntegrationTest < ActionController::IntegrationTest/
end
end
View
2 railties/test/generators/mailer_generator_test.rb
@@ -28,7 +28,7 @@ def test_check_class_collision
def test_invokes_default_test_framework
run_generator
- assert_file "test/controllers/notifier_test.rb" do |test|
+ assert_file "test/functional/notifier_test.rb" do |test|
assert_match /class NotifierTest < ActionMailer::TestCase/, test
assert_match /test "foo"/, test
assert_match /test "bar"/, test
View
2 railties/test/generators/model_generator_test.rb
@@ -153,7 +153,7 @@ def test_migration_is_removed_on_revoke
def test_invokes_default_test_framework
run_generator
- assert_file "test/models/account_test.rb", /class AccountTest < ActiveSupport::TestCase/
+ assert_file "test/unit/account_test.rb", /class AccountTest < ActiveSupport::TestCase/
assert_file "test/fixtures/accounts.yml", /name: MyString/, /age: 1/
end
View
2 railties/test/generators/observer_generator_test.rb
@@ -17,7 +17,7 @@ def test_invokes_default_orm_with_class_path
def test_invokes_default_test_framework
run_generator
- assert_file "test/observers/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/
+ assert_file "test/unit/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/
end
def test_logs_if_the_test_framework_cannot_be_found
View
10 railties/test/generators/resource_generator_test.rb
@@ -18,7 +18,7 @@ def test_files_from_inherited_invocation
%w(
app/models/account.rb
- test/models/account_test.rb
+ test/unit/account_test.rb
test/fixtures/accounts.yml
).each { |path| assert_file path }
@@ -33,10 +33,10 @@ def test_inherited_invocations_with_attributes
def test_resource_controller_with_pluralized_class_name
run_generator
assert_file "app/controllers/accounts_controller.rb", /class AccountsController < ApplicationController/
- assert_file "test/controllers/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/
+ assert_file "test/functional/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/
assert_file "app/helpers/accounts_helper.rb", /module AccountsHelper/
- assert_file "test/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/
+ assert_file "test/unit/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/
end
def test_resource_controller_with_actions
@@ -70,14 +70,14 @@ def test_singleton_resource
def test_plural_names_are_singularized
content = run_generator ["accounts".freeze]
assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/
- assert_file "test/models/account_test.rb", /class AccountTest/
+ assert_file "test/unit/account_test.rb", /class AccountTest/
assert_match /Plural version of the model detected, using singularized version. Override with --force-plural./, content
end
def test_plural_names_can_be_forced
content = run_generator ["accounts", "--force-plural"]
assert_file "app/models/accounts.rb", /class Accounts < ActiveRecord::Base/
- assert_file "test/models/accounts_test.rb", /class AccountsTest/
+ assert_file "test/unit/accounts_test.rb", /class AccountsTest/
assert_no_match /Plural version of the model detected/, content
end
View
8 railties/test/generators/scaffold_controller_generator_test.rb
@@ -54,7 +54,7 @@ def test_controller_skeleton_is_created
def test_helper_are_invoked_with_a_pluralized_name
run_generator
assert_file "app/helpers/users_helper.rb", /module UsersHelper/
- assert_file "test/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/
+ assert_file "test/unit/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/
end
def test_views_are_generated
@@ -72,7 +72,7 @@ def test_views_are_generated
def test_functional_tests
run_generator
- assert_file "test/controllers/users_controller_test.rb" do |content|
+ assert_file "test/functional/users_controller_test.rb" do |content|
assert_match /class UsersControllerTest < ActionController::TestCase/, content
assert_match /test "should get index"/, content
end
@@ -85,7 +85,7 @@ def test_generates_singleton_controller
assert_no_match /def index/, content
end
- assert_file "test/controllers/users_controller_test.rb" do |content|
+ assert_file "test/functional/users_controller_test.rb" do |content|
assert_no_match /test "should get index"/, content
end
@@ -95,7 +95,7 @@ def test_generates_singleton_controller
def test_skip_helper_if_required
run_generator ["User", "name:string", "age:integer", "--no-helper"]
assert_no_file "app/helpers/users_helper.rb"
- assert_no_file "test/helpers/users_helper_test.rb"
+ assert_no_file "test/unit/helpers/users_helper_test.rb"
end
def test_skip_layout_if_required
View
12 railties/test/generators/scaffold_generator_test.rb
@@ -12,7 +12,7 @@ def test_scaffold_on_invoke
# Model
assert_file "app/models/product_line.rb", /class ProductLine < ActiveRecord::Base/
- assert_file "test/models/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/
+ assert_file "test/unit/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/
assert_file "test/fixtures/product_lines.yml"
assert_migration "db/migrate/create_product_lines.rb"
@@ -59,7 +59,7 @@ def test_scaffold_on_invoke
end
end
- assert_file "test/controllers/product_lines_controller_test.rb",
+ assert_file "test/functional/product_lines_controller_test.rb",
/class ProductLinesControllerTest < ActionController::TestCase/
# Views
@@ -74,7 +74,7 @@ def test_scaffold_on_invoke
# Helpers
assert_file "app/helpers/product_lines_helper.rb"
- assert_file "test/helpers/product_lines_helper_test.rb"
+ assert_file "test/unit/helpers/product_lines_helper_test.rb"
# Stylesheets
assert_file "public/stylesheets/scaffold.css"
@@ -86,7 +86,7 @@ def test_scaffold_on_revoke
# Model
assert_no_file "app/models/product_line.rb"
- assert_no_file "test/models/product_line_test.rb"
+ assert_no_file "test/unit/product_line_test.rb"
assert_no_file "test/fixtures/product_lines.yml"
assert_no_migration "db/migrate/create_product_lines.rb"
@@ -97,15 +97,15 @@ def test_scaffold_on_revoke
# Controller
assert_no_file "app/controllers/product_lines_controller.rb"
- assert_no_file "test/controllers/product_lines_controller_test.rb"
+ assert_no_file "test/functional/product_lines_controller_test.rb"
# Views
assert_no_file "app/views/product_lines"
assert_no_file "app/views/layouts/product_lines.html.erb"
# Helpers
assert_no_file "app/helpers/product_lines_helper.rb"
- assert_no_file "test/helpers/product_lines_helper_test.rb"
+ assert_no_file "test/unit/helpers/product_lines_helper_test.rb"
# Stylesheets (should not be removed)
assert_file "public/stylesheets/scaffold.css"

3 comments on commit 9a865ee

@iain
iain commented on 9a865ee Mar 29, 2010

Why change it back?

@josevalim
Ruby on Rails member
Please sign in to comment.
Something went wrong with that request. Please try again.