Skip to content
This repository
Browse code

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)
  • Loading branch information...
commit 2a68f68aead9fd65ecac8062ca8efc15f5bab418 1 parent 0787cea
blowmage authored October 07, 2012

Showing 34 changed files with 187 additions and 146 deletions. Show diff stats Hide diff stats

  1. 2  actionmailer/lib/rails/generators/mailer/USAGE
  2. 2  guides/CHANGELOG.md
  3. 2  guides/source/action_mailer_basics.md
  4. 22  guides/source/command_line.md
  5. 18  guides/source/engines.md
  6. 12  guides/source/generators.md
  7. 24  guides/source/getting_started.md
  8. 30  guides/source/testing.md
  9. 3  railties/CHANGELOG.md
  10. 6  railties/lib/rails/generators/rails/app/app_generator.rb
  11. 8  railties/lib/rails/generators/rails/controller/USAGE
  12. 2  railties/lib/rails/generators/rails/helper/USAGE
  13. 4  railties/lib/rails/generators/rails/model/USAGE
  14. 2  railties/lib/rails/generators/rails/observer/USAGE
  15. 8  railties/lib/rails/generators/rails/scaffold_controller/USAGE
  16. 2  railties/lib/rails/generators/test_unit/controller/controller_generator.rb
  17. 2  railties/lib/rails/generators/test_unit/helper/helper_generator.rb
  18. 2  railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
  19. 2  railties/lib/rails/generators/test_unit/model/model_generator.rb
  20. 2  railties/lib/rails/generators/test_unit/observer/observer_generator.rb
  21. 2  railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
  22. 8  railties/lib/rails/tasks/statistics.rake
  23. 36  railties/lib/rails/test_unit/testing.rake
  24. 12  railties/test/application/rake_test.rb
  25. 6  railties/test/generators/app_generator_test.rb
  26. 8  railties/test/generators/controller_generator_test.rb
  27. 2  railties/test/generators/helper_generator_test.rb
  28. 2  railties/test/generators/mailer_generator_test.rb
  29. 6  railties/test/generators/model_generator_test.rb
  30. 50  railties/test/generators/namespaced_generators_test.rb
  31. 2  railties/test/generators/observer_generator_test.rb
  32. 10  railties/test/generators/resource_generator_test.rb
  33. 8  railties/test/generators/scaffold_controller_generator_test.rb
  34. 26  railties/test/generators/scaffold_generator_test.rb
2  actionmailer/lib/rails/generators/mailer/USAGE
@@ -13,6 +13,6 @@ Example:
13 13
     creates a Notifications mailer class, views, test, and fixtures:
14 14
         Mailer:     app/mailers/notifications.rb
15 15
         Views:      app/views/notifications/signup.erb [...]
16  
-        Test:       test/functional/notifications_test.rb
  16
+        Test:       test/mailers/notifications_test.rb
17 17
         Fixtures:   test/fixtures/notifications/signup [...]
18 18
 
2  guides/CHANGELOG.md
Source Rendered
... ...
@@ -1,3 +1,5 @@
1 1
 ## Rails 4.0.0 (unreleased) ##
2 2
 
  3
+*   Guides updated to reflect new test locations. *Mike Moore*
  4
+
3 5
 *   Guides have a responsive design. *Joe Fiorini*
2  guides/source/action_mailer_basics.md
Source Rendered
@@ -27,7 +27,7 @@ create  app/mailers/user_mailer.rb
27 27
 invoke  erb
28 28
 create    app/views/user_mailer
29 29
 invoke  test_unit
30  
-create    test/functional/user_mailer_test.rb
  30
+create    test/mailers/user_mailer_test.rb
31 31
 ```
32 32
 
33 33
 So we got the mailer, the views, and the tests.
22  guides/source/command_line.md
Source Rendered
@@ -134,10 +134,10 @@ Example:
134 134
     `rails generate controller CreditCard open debit credit close`
135 135
 
136 136
     Credit card controller with URLs like /credit_card/debit.
137  
-        Controller:      app/controllers/credit_card_controller.rb
138  
-        Functional Test: test/functional/credit_card_controller_test.rb
139  
-        Views:           app/views/credit_card/debit.html.erb [...]
140  
-        Helper:          app/helpers/credit_card_helper.rb
  137
+        Controller: app/controllers/credit_card_controller.rb
  138
+        Test:       test/controllers/credit_card_controller_test.rb
  139
+        Views:      app/views/credit_card/debit.html.erb [...]
  140
+        Helper:     app/helpers/credit_card_helper.rb
141 141
 ```
142 142
 
143 143
 The controller generator is expecting parameters in the form of `generate controller ControllerName action1 action2`. Let's make a `Greetings` controller with an action of **hello**, which will say something nice to us.
@@ -150,11 +150,11 @@ $ rails generate controller Greetings hello
150 150
      create    app/views/greetings
151 151
      create    app/views/greetings/hello.html.erb
152 152
      invoke  test_unit
153  
-     create    test/functional/greetings_controller_test.rb
  153
+     create    test/controllers/greetings_controller_test.rb
154 154
      invoke  helper
155 155
      create    app/helpers/greetings_helper.rb
156 156
      invoke    test_unit
157  
-     create      test/unit/helpers/greetings_helper_test.rb
  157
+     create      test/helpers/greetings_helper_test.rb
158 158
      invoke  assets
159 159
      invoke    coffee
160 160
      create      app/assets/javascripts/greetings.js.coffee
@@ -223,7 +223,7 @@ $ rails generate scaffold HighScore game:string score:integer
223 223
     create    db/migrate/20120528060026_create_high_scores.rb
224 224
     create    app/models/high_score.rb
225 225
     invoke    test_unit
226  
-    create      test/unit/high_score_test.rb
  226
+    create      test/models/high_score_test.rb
227 227
     create      test/fixtures/high_scores.yml
228 228
      route  resources :high_scores
229 229
     invoke  scaffold_controller
@@ -236,11 +236,11 @@ $ rails generate scaffold HighScore game:string score:integer
236 236
     create      app/views/high_scores/new.html.erb
237 237
     create      app/views/high_scores/_form.html.erb
238 238
     invoke    test_unit
239  
-    create      test/functional/high_scores_controller_test.rb
  239
+    create      test/controllers/high_scores_controller_test.rb
240 240
     invoke    helper
241 241
     create      app/helpers/high_scores_helper.rb
242 242
     invoke      test_unit
243  
-    create        test/unit/helpers/high_scores_helper_test.rb
  243
+    create        test/helpers/high_scores_helper_test.rb
244 244
     invoke  assets
245 245
     invoke    coffee
246 246
     create      app/assets/javascripts/high_scores.js.coffee
@@ -327,7 +327,7 @@ $ rails generate model Oops
327 327
       create    db/migrate/20120528062523_create_oops.rb
328 328
       create    app/models/oops.rb
329 329
       invoke    test_unit
330  
-      create      test/unit/oops_test.rb
  330
+      create      test/models/oops_test.rb
331 331
       create      test/fixtures/oops.yml
332 332
 ```
333 333
 ```bash
@@ -336,7 +336,7 @@ $ rails destroy model Oops
336 336
       remove    db/migrate/20120528062523_create_oops.rb
337 337
       remove    app/models/oops.rb
338 338
       invoke    test_unit
339  
-      remove      test/unit/oops_test.rb
  339
+      remove      test/models/oops_test.rb
340 340
       remove      test/fixtures/oops.yml
341 341
 ```
342 342
 
18  guides/source/engines.md
Source Rendered
@@ -130,7 +130,7 @@ end
130 130
 
131 131
 This line mounts the engine at the path `/blorgh`, which will make it accessible through the application only at that path.
132 132
 
133  
-Also in the test directory is the `test/integration` directory, where integration tests for the engine should be placed. Other directories can be created in the `test` directory also. For example, you may wish to create a `test/unit` directory for your unit tests.
  133
+Also in the test directory is the `test/integration` directory, where integration tests for the engine should be placed. Other directories can be created in the `test` directory also. For example, you may wish to create a `test/models` directory for your models tests.
134 134
 
135 135
 Providing engine functionality
136 136
 ------------------------------
@@ -152,7 +152,7 @@ invoke  active_record
152 152
 create    db/migrate/[timestamp]_create_blorgh_posts.rb
153 153
 create    app/models/blorgh/post.rb
154 154
 invoke    test_unit
155  
-create      test/unit/blorgh/post_test.rb
  155
+create      test/models/blorgh/post_test.rb
156 156
 create      test/fixtures/blorgh/posts.yml
157 157
  route  resources :posts
158 158
 invoke  scaffold_controller
@@ -165,11 +165,11 @@ create      app/views/blorgh/posts/show.html.erb
165 165
 create      app/views/blorgh/posts/new.html.erb
166 166
 create      app/views/blorgh/posts/_form.html.erb
167 167
 invoke    test_unit
168  
-create      test/functional/blorgh/posts_controller_test.rb
  168
+create      test/controllers/blorgh/posts_controller_test.rb
169 169
 invoke    helper
170 170
 create      app/helpers/blorgh/posts_helper.rb
171 171
 invoke      test_unit
172  
-create        test/unit/helpers/blorgh/posts_helper_test.rb
  172
+create        test/helpers/blorgh/posts_helper_test.rb
173 173
 invoke  assets
174 174
 invoke    js
175 175
 create      app/assets/javascripts/blorgh/posts.js
@@ -181,7 +181,7 @@ create    app/assets/stylesheets/scaffold.css
181 181
 
182 182
 The first thing that the scaffold generator does is invoke the `active_record` generator, which generates a migration and a model for the resource. Note here, however, that the migration is called `create_blorgh_posts` rather than the usual `create_posts`. This is due to the `isolate_namespace` method called in the `Blorgh::Engine` class's definition. The model here is also namespaced, being placed at `app/models/blorgh/post.rb` rather than `app/models/post.rb` due to the `isolate_namespace` call within the `Engine` class.
183 183
 
184  
-Next, the `test_unit` generator is invoked for this model, generating a unit test at `test/unit/blorgh/post_test.rb` (rather than `test/unit/post_test.rb`) and a fixture at `test/fixtures/blorgh/posts.yml` (rather than `test/fixtures/posts.yml`).
  184
+Next, the `test_unit` generator is invoked for this model, generating a model test at `test/models/blorgh/post_test.rb` (rather than `test/models/post_test.rb`) and a fixture at `test/fixtures/blorgh/posts.yml` (rather than `test/fixtures/posts.yml`).
185 185
 
186 186
 After that, a line for the resource is inserted into the `config/routes.rb` file for the engine. This line is simply `resources :posts`, turning the `config/routes.rb` file for the engine into this:
187 187
 
@@ -193,7 +193,7 @@ end
193 193
 
194 194
 Note here that the routes are drawn upon the `Blorgh::Engine` object rather than the `YourApp::Application` class. This is so that the engine routes are confined to the engine itself and can be mounted at a specific point as shown in the [test directory](#test-directory) section. This is also what causes the engine's routes to be isolated from those routes that are within the application. This is discussed further in the [Routes](#routes) section of this guide.
195 195
 
196  
-Next, the `scaffold_controller` generator is invoked, generating a controller called `Blorgh::PostsController` (at `app/controllers/blorgh/posts_controller.rb`) and its related views at `app/views/blorgh/posts`. This generator also generates a functional test for the controller (`test/functional/blorgh/posts_controller_test.rb`) and a helper (`app/helpers/blorgh/posts_controller.rb`).
  196
+Next, the `scaffold_controller` generator is invoked, generating a controller called `Blorgh::PostsController` (at `app/controllers/blorgh/posts_controller.rb`) and its related views at `app/views/blorgh/posts`. This generator also generates a test for the controller (`test/controllers/blorgh/posts_controller_test.rb`) and a helper (`app/helpers/blorgh/posts_controller.rb`).
197 197
 
198 198
 Everything this generator has created is neatly namespaced. The controller's class is defined within the `Blorgh` module:
199 199
 
@@ -261,7 +261,7 @@ invoke  active_record
261 261
 create    db/migrate/[timestamp]_create_blorgh_comments.rb
262 262
 create    app/models/blorgh/comment.rb
263 263
 invoke    test_unit
264  
-create      test/unit/blorgh/comment_test.rb
  264
+create      test/models/blorgh/comment_test.rb
265 265
 create      test/fixtures/blorgh/comments.yml
266 266
 ```
267 267
 
@@ -334,11 +334,11 @@ create  app/controllers/blorgh/comments_controller.rb
334 334
 invoke  erb
335 335
  exist    app/views/blorgh/comments
336 336
 invoke  test_unit
337  
-create    test/functional/blorgh/comments_controller_test.rb
  337
+create    test/controllers/blorgh/comments_controller_test.rb
338 338
 invoke  helper
339 339
 create    app/helpers/blorgh/comments_helper.rb
340 340
 invoke    test_unit
341  
-create      test/unit/helpers/blorgh/comments_helper_test.rb
  341
+create      test/helpers/blorgh/comments_helper_test.rb
342 342
 invoke  assets
343 343
 invoke    js
344 344
 create      app/assets/javascripts/blorgh/comments.js
12  guides/source/generators.md
Source Rendered
@@ -176,7 +176,7 @@ $ rails generate scaffold User name:string
176 176
       create    db/migrate/20091120125558_create_users.rb
177 177
       create    app/models/user.rb
178 178
       invoke    test_unit
179  
-      create      test/unit/user_test.rb
  179
+      create      test/models/user_test.rb
180 180
       create      test/fixtures/users.yml
181 181
        route  resources :users
182 182
       invoke  scaffold_controller
@@ -189,11 +189,11 @@ $ rails generate scaffold User name:string
189 189
       create      app/views/users/new.html.erb
190 190
       create      app/views/users/_form.html.erb
191 191
       invoke    test_unit
192  
-      create      test/functional/users_controller_test.rb
  192
+      create      test/controllers/users_controller_test.rb
193 193
       invoke    helper
194 194
       create      app/helpers/users_helper.rb
195 195
       invoke      test_unit
196  
-      create        test/unit/helpers/users_helper_test.rb
  196
+      create        test/helpers/users_helper_test.rb
197 197
       invoke  stylesheets
198 198
       create    app/assets/stylesheets/scaffold.css
199 199
 ```
@@ -350,7 +350,7 @@ $ rails generate scaffold Comment body:text
350 350
       create    db/migrate/20091120151323_create_comments.rb
351 351
       create    app/models/comment.rb
352 352
       invoke    shoulda
353  
-      create      test/unit/comment_test.rb
  353
+      create      test/models/comment_test.rb
354 354
       create      test/fixtures/comments.yml
355 355
        route    resources :comments
356 356
       invoke  scaffold_controller
@@ -364,11 +364,11 @@ $ rails generate scaffold Comment body:text
364 364
       create      app/views/comments/_form.html.erb
365 365
       create      app/views/layouts/comments.html.erb
366 366
       invoke    shoulda
367  
-      create      test/functional/comments_controller_test.rb
  367
+      create      test/controllers/comments_controller_test.rb
368 368
       invoke    my_helper
369 369
       create      app/helpers/comments_helper.rb
370 370
       invoke      shoulda
371  
-      create        test/unit/helpers/comments_helper_test.rb
  371
+      create        test/helpers/comments_helper_test.rb
372 372
 ```
373 373
 
374 374
 Fallbacks allow your generators to have a single responsibility, increasing code reuse and reducing the amount of duplication.
24  guides/source/getting_started.md
Source Rendered
@@ -185,11 +185,11 @@ invoke  erb
185 185
 create    app/views/welcome
186 186
 create    app/views/welcome/index.html.erb
187 187
 invoke  test_unit
188  
-create    test/functional/welcome_controller_test.rb
  188
+create    test/controllers/welcome_controller_test.rb
189 189
 invoke  helper
190 190
 create    app/helpers/welcome_helper.rb
191 191
 invoke    test_unit
192  
-create      test/unit/helpers/welcome_helper_test.rb
  192
+create      test/helpers/welcome_helper_test.rb
193 193
 invoke  assets
194 194
 invoke    coffee
195 195
 create      app/assets/javascripts/welcome.js.coffee
@@ -1239,7 +1239,7 @@ This command will generate four files:
1239 1239
 | -------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
1240 1240
 | db/migrate/20100207235629_create_comments.rb | Migration to create the comments table in your database (your name will include a different timestamp) |
1241 1241
 | app/models/comment.rb                        | The Comment model                                                                                      |
1242  
-| test/unit/comment_test.rb                    | Unit testing harness for the comments model                                                            |
  1242
+| test/models/comment_test.rb                  | Testing harness for the comments model                                                                 |
1243 1243
 | test/fixtures/comments.yml                   | Sample comments for use in testing                                                                     |
1244 1244
 
1245 1245
 First, take a look at `comment.rb`:
@@ -1360,15 +1360,15 @@ $ rails generate controller Comments
1360 1360
 
1361 1361
 This creates six files and one empty directory:
1362 1362
 
1363  
-| File/Directory                              | Purpose                                  |
1364  
-| ------------------------------------------- | ---------------------------------------- |
1365  
-| app/controllers/comments_controller.rb      | The Comments controller                  |
1366  
-| app/views/comments/                         | Views of the controller are stored here  |
1367  
-| test/functional/comments_controller_test.rb | The functional tests for the controller  |
1368  
-| app/helpers/comments_helper.rb              | A view helper file                       |
1369  
-| test/unit/helpers/comments_helper_test.rb   | The unit tests for the helper            |
1370  
-| app/assets/javascripts/comment.js.coffee    | CoffeeScript for the controller          |
1371  
-| app/assets/stylesheets/comment.css.scss     | Cascading style sheet for the controller |
  1363
+| File/Directory                               | Purpose                                  |
  1364
+| -------------------------------------------- | ---------------------------------------- |
  1365
+| app/controllers/comments_controller.rb       | The Comments controller                  |
  1366
+| app/views/comments/                          | Views of the controller are stored here  |
  1367
+| test/controllers/comments_controller_test.rb | The test for the controller              |
  1368
+| app/helpers/comments_helper.rb               | A view helper file                       |
  1369
+| test/helpers/comments_helper_test.rb         | The test for the helper                  |
  1370
+| app/assets/javascripts/comment.js.coffee     | CoffeeScript for the controller          |
  1371
+| app/assets/stylesheets/comment.css.scss      | Cascading style sheet for the controller |
1372 1372
 
1373 1373
 Like with any blog, our readers will create their comments directly after
1374 1374
 reading the post, and once they have added their comment, will be sent back to
30  guides/source/testing.md
Source Rendered
@@ -121,18 +121,18 @@ For this guide we will be using Rails _scaffolding_. It will create the model, a
121 121
 
122 122
 NOTE: For more information on Rails <i>scaffolding</i>, refer to [Getting Started with Rails](getting_started.html)
123 123
 
124  
-When you use `rails generate scaffold`, for a resource among other things it creates a test stub in the `test/unit` folder:
  124
+When you use `rails generate scaffold`, for a resource among other things it creates a test stub in the `test/models` folder:
125 125
 
126 126
 ```bash
127 127
 $ rails generate scaffold post title:string body:text
128 128
 ...
129 129
 create  app/models/post.rb
130  
-create  test/unit/post_test.rb
  130
+create  test/models/post_test.rb
131 131
 create  test/fixtures/posts.yml
132 132
 ...
133 133
 ```
134 134
 
135  
-The default test stub in `test/unit/post_test.rb` looks like this:
  135
+The default test stub in `test/models/post_test.rb` looks like this:
136 136
 
137 137
 ```ruby
138 138
 require 'test_helper'
@@ -225,9 +225,9 @@ TIP: You can see all these rake tasks and their descriptions by running `rake --
225 225
 Running a test is as simple as invoking the file containing the test cases through Ruby:
226 226
 
227 227
 ```bash
228  
-$ ruby -Itest test/unit/post_test.rb
  228
+$ ruby -Itest test/models/post_test.rb
229 229
 
230  
-Loaded suite unit/post_test
  230
+Loaded suite models/post_test
231 231
 Started
232 232
 .
233 233
 Finished in 0.023513 seconds.
@@ -240,9 +240,9 @@ This will run all the test methods from the test case. Note that `test_helper.rb
240 240
 You can also run a particular test method from the test case by using the `-n` switch with the `test method name`.
241 241
 
242 242
 ```bash
243  
-$ ruby -Itest test/unit/post_test.rb -n test_the_truth
  243
+$ ruby -Itest test/models/post_test.rb -n test_the_truth
244 244
 
245  
-Loaded suite unit/post_test
  245
+Loaded suite models/post_test
246 246
 Started
247 247
 .
248 248
 Finished in 0.023513 seconds.
@@ -271,7 +271,7 @@ F
271 271
 Finished in 0.102072 seconds.
272 272
 
273 273
   1) Failure:
274  
-test_should_not_save_post_without_title(PostTest) [/test/unit/post_test.rb:6]:
  274
+test_should_not_save_post_without_title(PostTest) [/test/models/post_test.rb:6]:
275 275
 <false> is not true.
276 276
 
277 277
 1 tests, 1 assertions, 1 failures, 0 errors
@@ -290,7 +290,7 @@ Running this test shows the friendlier assertion message:
290 290
 
291 291
 ```bash
292 292
   1) Failure:
293  
-test_should_not_save_post_without_title(PostTest) [/test/unit/post_test.rb:6]:
  293
+test_should_not_save_post_without_title(PostTest) [/test/models/post_test.rb:6]:
294 294
 Saved the post without a title.
295 295
 <false> is not true.
296 296
 ```
@@ -341,7 +341,7 @@ Finished in 0.082603 seconds.
341 341
   1) Error:
342 342
 test_should_report_error(PostTest):
343 343
 NameError: undefined local variable or method `some_undefined_variable' for #<PostTest:0x249d354>
344  
-    /test/unit/post_test.rb:6:in `test_should_report_error'
  344
+    /test/models/post_test.rb:6:in `test_should_report_error'
345 345
 
346 346
 1 tests, 0 assertions, 0 failures, 1 errors
347 347
 ```
@@ -420,7 +420,7 @@ You should test for things such as:
420 420
 * was the correct object stored in the response template?
421 421
 * was the appropriate message displayed to the user in the view?
422 422
 
423  
-Now that we have used Rails scaffold generator for our `Post` resource, it has already created the controller code and functional tests. You can take look at the file `posts_controller_test.rb` in the `test/functional` directory.
  423
+Now that we have used Rails scaffold generator for our `Post` resource, it has already created the controller code and tests. You can take look at the file `posts_controller_test.rb` in the `test/controllers` directory.
424 424
 
425 425
 Let me take you through one such test, `test_should_get_index` from the file `posts_controller_test.rb`.
426 426
 
@@ -762,12 +762,16 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai
762 762
 | ------------------------------- | ----------- |
763 763
 | `rake test`                     | Runs all unit, functional and integration tests. You can also simply run `rake` as the _test_ target is the default.|
764 764
 | `rake test:benchmark`           | Benchmark the performance tests|
765  
-| `rake test:functionals`         | Runs all the functional tests from `test/functional`|
  765
+| `rake test:controllers`         | Runs all the controller tests from `test/controllers`|
  766
+| `rake test:functionals`         | Runs all the functional tests from `test/controllers`, `test/mailers`, and `test/functional`|
  767
+| `rake test:helpers`             | Runs all the helper tests from `test/helpers`|
766 768
 | `rake test:integration`         | Runs all the integration tests from `test/integration`|
  769
+| `rake test:mailers`             | Runs all the mailer tests from `test/mailers`|
  770
+| `rake test:models`              | Runs all the model tests from `test/models`|
767 771
 | `rake test:profile`             | Profile the performance tests|
768 772
 | `rake test:recent`              | Tests recent changes|
769 773
 | `rake test:uncommitted`         | Runs all the tests which are uncommitted. Supports Subversion and Git|
770  
-| `rake test:units`               | Runs all the unit tests from `test/unit`|
  774
+| `rake test:units`               | Runs all the unit tests from `test/models`, `test/helpers`, and `test/unit`|
771 775
 
772 776
 
773 777
 Brief Note About `Test::Unit`
3  railties/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,8 @@
1 1
 ## Rails 4.0.0 (unreleased) ##
2 2
 
  3
+*   New test locations `test/models`, `test/helpers`, `test/controllers`, and
  4
+    `test/mailers`. Corresponding rake tasks added as well. *Mike Moore*
  5
+
3 6
 *   Set a different cache per environment for assets pipeline 
4 7
     through `config.assets.cache`.
5 8
 
6  railties/lib/rails/generators/rails/app/app_generator.rb
@@ -113,9 +113,11 @@ def script
113 113
 
114 114
     def test
115 115
       empty_directory_with_keep_file 'test/fixtures'
116  
-      empty_directory_with_keep_file 'test/functional'
  116
+      empty_directory_with_keep_file 'test/controllers'
  117
+      empty_directory_with_keep_file 'test/mailers'
  118
+      empty_directory_with_keep_file 'test/models'
  119
+      empty_directory_with_keep_file 'test/helpers'
117 120
       empty_directory_with_keep_file 'test/integration'
118  
-      empty_directory_with_keep_file 'test/unit'
119 121
 
120 122
       template 'test/performance/browsing_test.rb'
121 123
       template 'test/test_helper.rb'
8  railties/lib/rails/generators/rails/controller/USAGE
@@ -12,7 +12,7 @@ Example:
12 12
     `rails generate controller CreditCards open debit credit close`
13 13
 
14 14
     CreditCards controller with URLs like /credit_cards/debit.
15  
-        Controller:      app/controllers/credit_cards_controller.rb
16  
-        Functional Test: test/functional/credit_cards_controller_test.rb
17  
-        Views:           app/views/credit_cards/debit.html.erb [...]
18  
-        Helper:          app/helpers/credit_cards_helper.rb
  15
+        Controller: app/controllers/credit_cards_controller.rb
  16
+        Test:       test/controllers/credit_cards_controller_test.rb
  17
+        Views:      app/views/credit_cards/debit.html.erb [...]
  18
+        Helper:     app/helpers/credit_cards_helper.rb
2  railties/lib/rails/generators/rails/helper/USAGE
@@ -13,5 +13,5 @@ Example:
13 13
 
14 14
     Credit card helper.
15 15
         Helper:     app/helpers/credit_card_helper.rb
16  
-        Test:       test/unit/helpers/credit_card_helper_test.rb
  16
+        Test:       test/helpers/credit_card_helper_test.rb
17 17
 
4  railties/lib/rails/generators/rails/model/USAGE
@@ -74,7 +74,7 @@ Examples:
74 74
         For ActiveRecord and TestUnit it creates:
75 75
 
76 76
             Model:      app/models/account.rb
77  
-            Test:       test/unit/account_test.rb
  77
+            Test:       test/models/account_test.rb
78 78
             Fixtures:   test/fixtures/accounts.yml
79 79
             Migration:  db/migrate/XXX_add_accounts.rb
80 80
 
@@ -88,7 +88,7 @@ Examples:
88 88
 
89 89
             Module:     app/models/admin.rb
90 90
             Model:      app/models/admin/account.rb
91  
-            Test:       test/unit/admin/account_test.rb
  91
+            Test:       test/models/admin/account_test.rb
92 92
             Fixtures:   test/fixtures/admin/accounts.yml
93 93
             Migration:  db/migrate/XXX_add_admin_accounts.rb
94 94
 
2  railties/lib/rails/generators/rails/observer/USAGE
@@ -9,4 +9,4 @@ Example:
9 9
 
10 10
     For ActiveRecord and TestUnit it creates:
11 11
         Observer:   app/models/account_observer.rb
12  
-        TestUnit:   test/unit/account_observer_test.rb
  12
+        TestUnit:   test/models/account_observer_test.rb
8  railties/lib/rails/generators/rails/scaffold_controller/USAGE
@@ -13,7 +13,7 @@ Example:
13 13
     `rails generate scaffold_controller CreditCard`
14 14
 
15 15
     Credit card controller with URLs like /credit_card/debit.
16  
-        Controller:      app/controllers/credit_cards_controller.rb
17  
-        Functional Test: test/functional/credit_cards_controller_test.rb
18  
-        Views:           app/views/credit_cards/index.html.erb [...]
19  
-        Helper:          app/helpers/credit_cards_helper.rb
  16
+        Controller: app/controllers/credit_cards_controller.rb
  17
+        Test:       test/controllers/credit_cards_controller_test.rb
  18
+        Views:      app/views/credit_cards/index.html.erb [...]
  19
+        Helper:     app/helpers/credit_cards_helper.rb
2  railties/lib/rails/generators/test_unit/controller/controller_generator.rb
@@ -8,7 +8,7 @@ class ControllerGenerator < Base
8 8
 
9 9
       def create_test_files
10 10
         template 'functional_test.rb',
11  
-                 File.join('test/functional', class_path, "#{file_name}_controller_test.rb")
  11
+                 File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
12 12
       end
13 13
     end
14 14
   end
2  railties/lib/rails/generators/test_unit/helper/helper_generator.rb
@@ -6,7 +6,7 @@ class HelperGenerator < Base
6 6
       check_class_collision :suffix => "HelperTest"
7 7
 
8 8
       def create_helper_files
9  
-        template 'helper_test.rb', File.join('test/unit/helpers', class_path, "#{file_name}_helper_test.rb")
  9
+        template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb")
10 10
       end
11 11
     end
12 12
   end
2  railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
@@ -7,7 +7,7 @@ class MailerGenerator < Base
7 7
       check_class_collision :suffix => "Test"
8 8
 
9 9
       def create_test_files
10  
-        template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb")
  10
+        template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb")
11 11
       end
12 12
     end
13 13
   end
2  railties/lib/rails/generators/test_unit/model/model_generator.rb
@@ -9,7 +9,7 @@ class ModelGenerator < Base
9 9
       check_class_collision :suffix => "Test"
10 10
 
11 11
       def create_test_file
12  
-        template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
  12
+        template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
13 13
       end
14 14
 
15 15
       hook_for :fixture_replacement
2  railties/lib/rails/generators/test_unit/observer/observer_generator.rb
@@ -6,7 +6,7 @@ class ObserverGenerator < Base
6 6
       check_class_collision :suffix => "ObserverTest"
7 7
 
8 8
       def create_test_files
9  
-        template 'unit_test.rb',  File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
  9
+        template 'unit_test.rb',  File.join('test/models', class_path, "#{file_name}_observer_test.rb")
10 10
       end
11 11
     end
12 12
   end
2  railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -12,7 +12,7 @@ class ScaffoldGenerator < Base
12 12
 
13 13
       def create_test_files
14 14
         template "functional_test.rb",
15  
-                 File.join("test/functional", controller_class_path, "#{controller_file_name}_controller_test.rb")
  15
+                 File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
16 16
       end
17 17
 
18 18
       private
8  railties/lib/rails/tasks/statistics.rake
@@ -6,9 +6,13 @@ STATS_DIRECTORIES = [
6 6
   %w(Javascripts        app/assets/javascripts),
7 7
   %w(Libraries          lib/),
8 8
   %w(APIs               app/apis),
  9
+  %w(Controller\ tests  test/controllers),
  10
+  %w(Helper\ tests      test/helpers),
  11
+  %w(Model\ tests       test/models),
  12
+  %w(Mailer\ tests      test/mailers),
9 13
   %w(Integration\ tests test/integration),
10  
-  %w(Functional\ tests  test/functional),
11  
-  %w(Unit\ tests        test/unit)
  14
+  %w(Functional\ tests\ (old)  test/functional),
  15
+  %w(Unit\ tests \ (old)       test/unit)
12 16
 ].collect { |name, dir| [ name, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
13 17
 
14 18
 desc "Report code statistics (KLOCs, etc) from the application"
36  railties/lib/rails/test_unit/testing.rake
@@ -15,11 +15,11 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
15 15
       # Support subdirs in app/models and app/controllers
16 16
       modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
17 17
 
18  
-      # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
  18
+      # For modified files in app/ run the tests for it. ex. /test/controllers/account_controller.rb
19 19
       test = "#{modified_test_path}/#{source_file}_test.rb"
20 20
       tests.push test if File.exist?(test)
21 21
 
22  
-      # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
  22
+      # For modified files in app, run tests in subdirs too. ex. /test/controllers/account/*_test.rb
23 23
       test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
24 24
       FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
25 25
 
@@ -74,7 +74,9 @@ namespace :test do
74 74
   Rake::TestTask.new(:recent => "test:prepare") do |t|
75 75
     since = TEST_CHANGES_SINCE
76 76
     touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
  77
+      recent_tests('app/models/**/*.rb', 'test/models', since) +
77 78
       recent_tests('app/models/**/*.rb', 'test/unit', since) +
  79
+      recent_tests('app/controllers/**/*.rb', 'test/controllers', since) +
78 80
       recent_tests('app/controllers/**/*.rb', 'test/functional', since)
79 81
 
80 82
     t.libs << 'test'
@@ -95,8 +97,10 @@ namespace :test do
95 97
       models      = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
96 98
       controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
97 99
 
98  
-      unit_tests       = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
99  
-      functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
  100
+      unit_tests       = models.map { |model| "test/models/#{File.basename(model, '.rb')}_test.rb" } +
  101
+                         models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } +
  102
+      functional_tests = controllers.map { |controller| "test/controllers/#{File.basename(controller, '.rb')}_test.rb" } +
  103
+                         controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
100 104
       (unit_tests + functional_tests).uniq.select { |file| File.exist?(file) }
101 105
     end
102 106
 
@@ -108,14 +112,34 @@ namespace :test do
108 112
     t.libs << "test"
109 113
   end
110 114
 
  115
+  Rails::SubTestTask.new(:models => "test:prepare") do |t|
  116
+    t.libs << "test"
  117
+    t.pattern = 'test/models/**/*_test.rb'
  118
+  end
  119
+
  120
+  Rails::SubTestTask.new(:helpers => "test:prepare") do |t|
  121
+    t.libs << "test"
  122
+    t.pattern = 'test/helpers/**/*_test.rb'
  123
+  end
  124
+
111 125
   Rails::SubTestTask.new(:units => "test:prepare") do |t|
112 126
     t.libs << "test"
113  
-    t.pattern = 'test/unit/**/*_test.rb'
  127
+    t.pattern = 'test/{models,helpers,unit}/**/*_test.rb'
  128
+  end
  129
+
  130
+  Rails::SubTestTask.new(:controllers => "test:prepare") do |t|
  131
+    t.libs << "test"
  132
+    t.pattern = 'test/controllers/**/*_test.rb'
  133
+  end
  134
+
  135
+  Rails::SubTestTask.new(:mailers => "test:prepare") do |t|
  136
+    t.libs << "test"
  137
+    t.pattern = 'test/mailers/**/*_test.rb'
114 138
   end
115 139
 
116 140
   Rails::SubTestTask.new(:functionals => "test:prepare") do |t|
117 141
     t.libs << "test"
118  
-    t.pattern = 'test/functional/**/*_test.rb'
  142
+    t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb'
119 143
   end
120 144
 
121 145
   Rails::SubTestTask.new(:integration => "test:prepare") do |t|
12  railties/test/application/rake_test.rb
@@ -86,12 +86,12 @@ def test_code_statistics_sanity
86 86
     def test_rake_test_error_output
87 87
       Dir.chdir(app_path){ `rake db:migrate` }
88 88
 
89  
-      app_file "test/unit/one_unit_test.rb", <<-RUBY
90  
-        raise 'unit'
  89
+      app_file "test/models/one_model_test.rb", <<-RUBY
  90
+        raise 'models'
91 91
       RUBY
92 92
 
93  
-      app_file "test/functional/one_functional_test.rb", <<-RUBY
94  
-        raise 'functional'
  93
+      app_file "test/controllers/one_controller_test.rb", <<-RUBY
  94
+        raise 'controllers'
95 95
       RUBY
96 96
 
97 97
       app_file "test/integration/one_integration_test.rb", <<-RUBY
@@ -100,8 +100,8 @@ def test_rake_test_error_output
100 100
 
101 101
       silence_stderr do
102 102
         output = Dir.chdir(app_path) { `rake test 2>&1` }
103  
-        assert_match 'unit', output
104  
-        assert_match 'functional', output
  103
+        assert_match 'models', output
  104
+        assert_match 'controllers', output
105 105
         assert_match 'integration', output
106 106
       end
107 107
     end
6  railties/test/generators/app_generator_test.rb
@@ -26,10 +26,12 @@
26 26
   log
27 27
   script/rails
28 28
   test/fixtures
29  
-  test/functional
  29
+  test/controllers
  30
+  test/models
  31
+  test/helpers
  32
+  test/mailers
30 33
   test/integration
31 34
   test/performance
32  
-  test/unit
33 35
   vendor
34 36
   vendor/assets
35 37
   tmp/cache
8  railties/test/generators/controller_generator_test.rb
@@ -28,13 +28,13 @@ def test_check_class_collision
28 28
   def test_invokes_helper
29 29
     run_generator
30 30
     assert_file "app/helpers/account_helper.rb"
31  
-    assert_file "test/unit/helpers/account_helper_test.rb"
  31
+    assert_file "test/helpers/account_helper_test.rb"
32 32
   end
33 33
 
34 34
   def test_does_not_invoke_helper_if_required
35 35
     run_generator ["account", "--skip-helper"]
36 36
     assert_no_file "app/helpers/account_helper.rb"
37  
-    assert_no_file "test/unit/helpers/account_helper_test.rb"
  37
+    assert_no_file "test/helpers/account_helper_test.rb"
38 38
   end
39 39
 
40 40
   def test_invokes_assets
@@ -45,12 +45,12 @@ def test_invokes_assets
45 45
 
46 46
   def test_invokes_default_test_framework
47 47
     run_generator
48  
-    assert_file "test/functional/account_controller_test.rb"
  48
+    assert_file "test/controllers/account_controller_test.rb"
49 49
   end
50 50
 
51 51
   def test_does_not_invoke_test_framework_if_required
52 52
     run_generator ["account", "--no-test-framework"]
53  
-    assert_no_file "test/functional/account_controller_test.rb"
  53
+    assert_no_file "test/controllers/account_controller_test.rb"
54 54
   end
55 55
 
56 56
   def test_invokes_default_template_engine
2  railties/test/generators/helper_generator_test.rb
@@ -15,7 +15,7 @@ def test_helper_skeleton_is_created
15 15
 
16 16
   def test_invokes_default_test_framework
17 17
     run_generator
18  
-    assert_file "test/unit/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/
  18
+    assert_file "test/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/
19 19
   end
20 20
 
21 21
   def test_logs_if_the_test_framework_cannot_be_found
2  railties/test/generators/mailer_generator_test.rb
@@ -29,7 +29,7 @@ def test_check_class_collision
29 29
 
30 30
   def test_invokes_default_test_framework
31 31
     run_generator
32  
-    assert_file "test/functional/notifier_test.rb" do |test|
  32
+    assert_file "test/mailers/notifier_test.rb" do |test|
33 33
       assert_match(/class NotifierTest < ActionMailer::TestCase/, test)
34 34
       assert_match(/test "foo"/, test)
35 35
       assert_match(/test "bar"/, test)
6  railties/test/generators/model_generator_test.rb
@@ -157,7 +157,7 @@ def test_migration_with_missing_attribute_type_and_with_index
157 157
         assert_match(/create_table :products/, up)
158 158
         assert_match(/t\.string :name/, up)
159 159
         assert_match(/t\.integer :supplier_id/, up)
160  
-        
  160
+
161 161
         assert_match(/add_index :products, :name/, up)
162 162
         assert_match(/add_index :products, :supplier_id/, up)
163 163
         assert_no_match(/add_index :products, :year/, up)
@@ -181,7 +181,7 @@ def test_add_migration_with_attributes_index_declaration_and_attribute_options
181 181
       assert_match(/add_index :products, :discount, unique: true/, content)
182 182
     end
183 183
   end
184  
-  
  184
+
185 185
   def test_migration_without_timestamps
186 186
     ActiveRecord::Base.timestamped_migrations = false
187 187
     run_generator ["account"]
@@ -269,7 +269,7 @@ def test_existing_migration_is_removed_on_force
269 269
 
270 270
   def test_invokes_default_test_framework
271 271
     run_generator
272  
-    assert_file "test/unit/account_test.rb", /class AccountTest < ActiveSupport::TestCase/
  272
+    assert_file "test/models/account_test.rb", /class AccountTest < ActiveSupport::TestCase/
273 273
     assert_file "test/fixtures/accounts.yml", /name: MyString/, /age: 1/
274 274
   end
275 275
 
50  railties/test/generators/namespaced_generators_test.rb
@@ -25,7 +25,7 @@ def test_namespaced_controller_skeleton_is_created
25 25
                 /module TestApp/,
26 26
                 /  class AccountController < ApplicationController/
27 27
 
28  
-    assert_file "test/functional/test_app/account_controller_test.rb",
  28
+    assert_file "test/controllers/test_app/account_controller_test.rb",
29 29
                 /module TestApp/,
30 30
                 /  class AccountControllerTest/
31 31
   end
@@ -46,12 +46,12 @@ def test_namespaced_controller_with_additional_namespace
46 46
   def test_helpr_is_also_namespaced
47 47
     run_generator
48 48
     assert_file "app/helpers/test_app/account_helper.rb", /module TestApp/, /  module AccountHelper/
49  
-    assert_file "test/unit/helpers/test_app/account_helper_test.rb", /module TestApp/, /  class AccountHelperTest/
  49
+    assert_file "test/helpers/test_app/account_helper_test.rb", /module TestApp/, /  class AccountHelperTest/
50 50
   end
51 51
 
52 52
   def test_invokes_default_test_framework
53 53
     run_generator
54  
-    assert_file "test/functional/test_app/account_controller_test.rb"
  54
+    assert_file "test/controllers/test_app/account_controller_test.rb"
55 55
   end
56 56
 
57 57
   def test_invokes_default_template_engine
@@ -136,7 +136,7 @@ def test_migration_with_nested_namespace_without_pluralization
136 136
 
137 137
   def test_invokes_default_test_framework
138 138
     run_generator
139  
-    assert_file "test/unit/test_app/account_test.rb", /module TestApp/, /class AccountTest < ActiveSupport::TestCase/
  139
+    assert_file "test/models/test_app/account_test.rb", /module TestApp/, /class AccountTest < ActiveSupport::TestCase/
140 140
     assert_file "test/fixtures/test_app/accounts.yml", /name: MyString/, /age: 1/
141 141
   end
142 142
 end
@@ -158,7 +158,7 @@ def test_invokes_default_orm_with_class_path
158 158
 
159 159
   def test_invokes_default_test_framework
160 160
     run_generator
161  
-    assert_file "test/unit/test_app/account_observer_test.rb", /module TestApp/, /  class AccountObserverTest < ActiveSupport::TestCase/
  161
+    assert_file "test/models/test_app/account_observer_test.rb", /module TestApp/, /  class AccountObserverTest < ActiveSupport::TestCase/
162 162
   end
163 163
 end
164 164
 
@@ -186,7 +186,7 @@ def test_mailer_with_i18n_helper
186 186
 
187 187
   def test_invokes_default_test_framework
188 188
     run_generator
189  
-    assert_file "test/functional/test_app/notifier_test.rb" do |test|
  189
+    assert_file "test/mailers/test_app/notifier_test.rb" do |test|
190 190
       assert_match(/module TestApp/, test)
191 191
       assert_match(/class NotifierTest < ActionMailer::TestCase/, test)
192 192
       assert_match(/test "foo"/, test)
@@ -225,7 +225,7 @@ def test_scaffold_on_invoke
225 225
 
226 226
     # Model
227 227
     assert_file "app/models/test_app/product_line.rb", /module TestApp\n  class ProductLine < ActiveRecord::Base/
228  
-    assert_file "test/unit/test_app/product_line_test.rb", /module TestApp\n  class ProductLineTest < ActiveSupport::TestCase/
  228
+    assert_file "test/models/test_app/product_line_test.rb", /module TestApp\n  class ProductLineTest < ActiveSupport::TestCase/
229 229
     assert_file "test/fixtures/test_app/product_lines.yml"
230 230
     assert_migration "db/migrate/create_test_app_product_lines.rb"
231 231
 
@@ -240,7 +240,7 @@ def test_scaffold_on_invoke
240 240
                 /module TestApp/,
241 241
                 /class ProductLinesController < ApplicationController/
242 242
 
243  
-    assert_file "test/functional/test_app/product_lines_controller_test.rb",
  243
+    assert_file "test/controllers/test_app/product_lines_controller_test.rb",
244 244
                 /module TestApp\n  class ProductLinesControllerTest < ActionController::TestCase/
245 245
 
246 246
     # Views
@@ -255,7 +255,7 @@ def test_scaffold_on_invoke
255 255
 
256 256
     # Helpers
257 257
     assert_file "app/helpers/test_app/product_lines_helper.rb"
258  
-    assert_file "test/unit/helpers/test_app/product_lines_helper_test.rb"
  258
+    assert_file "test/helpers/test_app/product_lines_helper_test.rb"
259 259
 
260 260
     # Stylesheets
261 261
     assert_file "app/assets/stylesheets/scaffold.css"
@@ -267,7 +267,7 @@ def test_scaffold_on_revoke
267 267
 
268 268
     # Model
269 269
     assert_no_file "app/models/test_app/product_line.rb"
270  
-    assert_no_file "test/unit/test_app/product_line_test.rb"
  270
+    assert_no_file "test/models/test_app/product_line_test.rb"
271 271
     assert_no_file "test/fixtures/test_app/product_lines.yml"
272 272
     assert_no_migration "db/migrate/create_test_app_product_lines.rb"
273 273
 
@@ -278,7 +278,7 @@ def test_scaffold_on_revoke
278 278
 
279 279
     # Controller
280 280
     assert_no_file "app/controllers/test_app/product_lines_controller.rb"
281  
-    assert_no_file "test/functional/test_app/product_lines_controller_test.rb"
  281
+    assert_no_file "test/controllers/test_app/product_lines_controller_test.rb"
282 282
 
283 283
     # Views
284 284
     assert_no_file "app/views/test_app/product_lines"
@@ -286,7 +286,7 @@ def test_scaffold_on_revoke
286 286
 
287 287
     # Helpers
288 288
     assert_no_file "app/helpers/test_app/product_lines_helper.rb"
289  
-    assert_no_file "test/unit/helpers/test_app/product_lines_helper_test.rb"
  289
+    assert_no_file "test/helpers/test_app/product_lines_helper_test.rb"
290 290
 
291 291
     # Stylesheets (should not be removed)
292 292
     assert_file "app/assets/stylesheets/scaffold.css"
@@ -298,7 +298,7 @@ def test_scaffold_with_namespace_on_invoke
298 298
     # Model
299 299
     assert_file "app/models/test_app/admin.rb", /module TestApp\n  module Admin/
300 300
     assert_file "app/models/test_app/admin/role.rb", /module TestApp\n  class Admin::Role < ActiveRecord::Base/
301  
-    assert_file "test/unit/test_app/admin/role_test.rb", /module TestApp\n  class Admin::RoleTest < ActiveSupport::TestCase/
  301
+    assert_file "test/models/test_app/admin/role_test.rb", /module TestApp\n  class Admin::RoleTest < ActiveSupport::TestCase/
302 302
     assert_file "test/fixtures/test_app/admin/roles.yml"
303 303
     assert_migration "db/migrate/create_test_app_admin_roles.rb"
304 304
 
@@ -312,7 +312,7 @@ def test_scaffold_with_namespace_on_invoke
312 312
       assert_match(/module TestApp\n  class Admin::RolesController < ApplicationController/, content)
313 313
     end
314 314
 
315  
-    assert_file "test/functional/test_app/admin/roles_controller_test.rb",
  315
+    assert_file "test/controllers/test_app/admin/roles_controller_test.rb",
316 316
                 /module TestApp\n  class Admin::RolesControllerTest < ActionController::TestCase/
317 317
 
318 318
     # Views
@@ -327,7 +327,7 @@ def test_scaffold_with_namespace_on_invoke
327 327
 
328 328
     # Helpers
329 329
     assert_file "app/helpers/test_app/admin/roles_helper.rb"
330  
-    assert_file "test/unit/helpers/test_app/admin/roles_helper_test.rb"
  330
+    assert_file "test/helpers/test_app/admin/roles_helper_test.rb"
331 331
 
332 332
     # Stylesheets
333 333
     assert_file "app/assets/stylesheets/scaffold.css"
@@ -340,7 +340,7 @@ def test_scaffold_with_namespace_on_revoke
340 340
     # Model
341 341
     assert_file "app/models/test_app/admin.rb"	# ( should not be remove )
342 342
     assert_no_file "app/models/test_app/admin/role.rb"
343  
-    assert_no_file "test/unit/test_app/admin/role_test.rb"
  343
+    assert_no_file "test/models/test_app/admin/role_test.rb"
344 344
     assert_no_file "test/fixtures/test_app/admin/roles.yml"
345 345
     assert_no_migration "db/migrate/create_test_app_admin_roles.rb"
346 346
 
@@ -351,7 +351,7 @@ def test_scaffold_with_namespace_on_revoke
351 351
 
352 352
     # Controller
353 353
     assert_no_file "app/controllers/test_app/admin/roles_controller.rb"
354  
-    assert_no_file "test/functional/test_app/admin/roles_controller_test.rb"
  354
+    assert_no_file "test/controllers/test_app/admin/roles_controller_test.rb"
355 355
 
356 356
     # Views
357 357
     assert_no_file "app/views/test_app/admin/roles"
@@ -359,19 +359,19 @@ def test_scaffold_with_namespace_on_revoke
359 359
 
360 360
     # Helpers
361 361
     assert_no_file "app/helpers/test_app/admin/roles_helper.rb"
362  
-    assert_no_file "test/unit/helpers/test_app/admin/roles_helper_test.rb"
  362
+    assert_no_file "test/helpers/test_app/admin/roles_helper_test.rb"
363 363
 
364 364
     # Stylesheets (should not be removed)
365 365
     assert_file "app/assets/stylesheets/scaffold.css"
366 366
   end
367  
-  
  367
+
368 368
   def test_scaffold_with_nested_namespace_on_invoke
369 369
     run_generator [ "admin/user/special/role", "name:string", "description:string" ]
370 370
 
371 371
     # Model
372 372
     assert_file "app/models/test_app/admin/user/special.rb", /module TestApp\n  module Admin/
373 373
     assert_file "app/models/test_app/admin/user/special/role.rb", /module TestApp\n  class Admin::User::Special::Role < ActiveRecord::Base/
374  
-    assert_file "test/unit/test_app/admin/user/special/role_test.rb", /module TestApp\n  class Admin::User::Special::RoleTest < ActiveSupport::TestCase/
  374
+    assert_file "test/models/test_app/admin/user/special/role_test.rb", /module TestApp\n  class Admin::User::Special::RoleTest < ActiveSupport::TestCase/
375 375
     assert_file "test/fixtures/test_app/admin/user/special/roles.yml"
376 376
     assert_migration "db/migrate/create_test_app_admin_user_special_roles.rb"
377 377
 
@@ -385,7 +385,7 @@ def test_scaffold_with_nested_namespace_on_invoke
385 385
       assert_match(/module TestApp\n  class Admin::User::Special::RolesController < ApplicationController/, content)
386 386
     end
387 387
 
388  
-    assert_file "test/functional/test_app/admin/user/special/roles_controller_test.rb",
  388
+    assert_file "test/controllers/test_app/admin/user/special/roles_controller_test.rb",
389 389
                 /module TestApp\n  class Admin::User::Special::RolesControllerTest < ActionController::TestCase/
390 390
 
391 391
     # Views
@@ -400,7 +400,7 @@ def test_scaffold_with_nested_namespace_on_invoke
400 400
 
401 401
     # Helpers
402 402
     assert_file "app/helpers/test_app/admin/user/special/roles_helper.rb"
403  
-    assert_file "test/unit/helpers/test_app/admin/user/special/roles_helper_test.rb"
  403
+    assert_file "test/helpers/test_app/admin/user/special/roles_helper_test.rb"
404 404
 
405 405
     # Stylesheets
406 406
     assert_file "app/assets/stylesheets/scaffold.css"
@@ -413,7 +413,7 @@ def test_scaffold_with_nested_namespace_on_revoke
413 413
     # Model
414 414
     assert_file "app/models/test_app/admin/user/special.rb"	# ( should not be remove )
415 415
     assert_no_file "app/models/test_app/admin/user/special/role.rb"
416  
-    assert_no_file "test/unit/test_app/admin/user/special/role_test.rb"
  416
+    assert_no_file "test/models/test_app/admin/user/special/role_test.rb"
417 417
     assert_no_file "test/fixtures/test_app/admin/user/special/roles.yml"
418 418
     assert_no_migration "db/migrate/create_test_app_admin_user_special_roles.rb"
419 419
 
@@ -424,14 +424,14 @@ def test_scaffold_with_nested_namespace_on_revoke
424 424
 
425 425
     # Controller
426 426
     assert_no_file "app/controllers/test_app/admin/user/special/roles_controller.rb"
427  
-    assert_no_file "test/functional/test_app/admin/user/special/roles_controller_test.rb"
  427
+    assert_no_file "test/controllers/test_app/admin/user/special/roles_controller_test.rb"
428 428
 
429 429
     # Views
430 430
     assert_no_file "app/views/test_app/admin/user/special/roles"
431 431
 
432 432
     # Helpers
433 433
     assert_no_file "app/helpers/test_app/admin/user/special/roles_helper.rb"
434  
-    assert_no_file "test/unit/helpers/test_app/admin/user/special/roles_helper_test.rb"
  434
+    assert_no_file "test/helpers/test_app/admin/user/special/roles_helper_test.rb"
435 435
 
436 436
     # Stylesheets (should not be removed)
437 437
     assert_file "app/assets/stylesheets/scaffold.css"
2  railties/test/generators/observer_generator_test.rb
@@ -17,7 +17,7 @@ def test_invokes_default_orm_with_class_path
17 17
 
18 18
   def test_invokes_default_test_framework
19 19
     run_generator
20  
-    assert_file "test/unit/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/
  20
+    assert_file "test/models/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/
21 21
   end
22 22
 
23 23
   def test_logs_if_the_test_framework_cannot_be_found
10  railties/test/generators/resource_generator_test.rb
@@ -18,7 +18,7 @@ def test_files_from_inherited_invocation
18 18
 
19 19
     %w(
20 20
       app/models/account.rb
21  
-      test/unit/account_test.rb
  21
+      test/models/account_test.rb
22 22
       test/fixtures/accounts.yml
23 23
     ).each { |path| assert_file path }
24 24
 
@@ -33,10 +33,10 @@ def test_inherited_invocations_with_attributes
33 33
   def test_resource_controller_with_pluralized_class_name
34 34
     run_generator
35 35
     assert_file "app/controllers/accounts_controller.rb", /class AccountsController < ApplicationController/
36  
-    assert_file "test/functional/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/
  36
+    assert_file "test/controllers/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/
37 37
 
38 38
     assert_file "app/helpers/accounts_helper.rb", /module AccountsHelper/
39  
-    assert_file "test/unit/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/
  39
+    assert_file "test/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/
40 40
   end
41 41
 
42 42
   def test_resource_controller_with_actions
@@ -62,14 +62,14 @@ def test_resource_routes_are_added
62 62
   def test_plural_names_are_singularized
63 63
     content = run_generator ["accounts".freeze]
64 64
     assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/
65  
-    assert_file "test/unit/account_test.rb", /class AccountTest/
  65
+    assert_file "test/models/account_test.rb", /class AccountTest/
66 66
     assert_match(/Plural version of the model detected, using singularized version. Override with --force-plural./, content)
67 67
   end
68 68
 
69 69
   def test_plural_names_can_be_forced
70 70
     content = run_generator ["accounts", "--force-plural"]
71 71
     assert_file "app/models/accounts.rb", /class Accounts < ActiveRecord::Base/
72  
-    assert_file "test/unit/accounts_test.rb", /class AccountsTest/
  72
+    assert_file "test/models/accounts_test.rb", /class AccountsTest/
73 73
     assert_no_match(/Plural version of the model detected/, content)
74 74
   end
75 75
 
8  railties/test/generators/scaffold_controller_generator_test.rb
@@ -57,7 +57,7 @@ def test_controller_skeleton_is_created
57 57
   def test_helper_are_invoked_with_a_pluralized_name
58 58
     run_generator
59 59
     assert_file "app/helpers/users_helper.rb", /module UsersHelper/
60  
-    assert_file "test/unit/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/
  60
+    assert_file "test/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/
61 61
   end
62 62
 
63 63
   def test_views_are_generated
@@ -75,7 +75,7 @@ def test_views_are_generated
75 75
   def test_functional_tests
76 76
     run_generator
77 77
 
78  
-    assert_file "test/functional/users_controller_test.rb" do |content|
  78
+    assert_file "test/controllers/users_controller_test.rb" do |content|
79 79
       assert_match(/class UsersControllerTest < ActionController::TestCase/, content)
80 80
       assert_match(/test "should get index"/, content)
81 81
       assert_match(/post :create, user: \{ age: @user.age, name: @user.name \}/, content)
@@ -86,7 +86,7 @@ def test_functional_tests
86 86
   def test_functional_tests_without_attributes
87 87
     run_generator ["User"]
88 88
 
89  
-    assert_file "test/functional/users_controller_test.rb" do |content|
  89
+    assert_file "test/controllers/users_controller_test.rb" do |content|