aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit
diff options
context:
space:
mode:
authorMike Moore <mike@blowmage.com>2012-10-07 22:59:42 -0600
committerMike Moore <mike@blowmage.com>2012-10-09 17:53:56 -0600
commit2a68f68aead9fd65ecac8062ca8efc15f5bab418 (patch)
tree632bf64b5a6974c2e47d5300ff8d15a143133af5 /railties/lib/rails/test_unit
parent0787cea3bb5e6f2c216e71090732bc55ee03c7dc (diff)
downloadrails-2a68f68aead9fd65ecac8062ca8efc15f5bab418.tar.gz
rails-2a68f68aead9fd65ecac8062ca8efc15f5bab418.tar.bz2
rails-2a68f68aead9fd65ecac8062ca8efc15f5bab418.zip
Update test locations
Change the default test locations to avoid confusion around the common testing terms "unit" and "functional". Add new rake tasks for the new locations, while maintaining backwards compatibility with the old rake tasks. New testing locations are as follows: app/models -> test/models (was test/units) app/helpers -> test/helpers (was test/units/helpers) app/controllers -> test/controllers (was test/functional) app/mailers -> test/mailers (was test/functional)
Diffstat (limited to 'railties/lib/rails/test_unit')
-rw-r--r--railties/lib/rails/test_unit/testing.rake36
1 files changed, 30 insertions, 6 deletions
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|