Skip to content

Commit a413111

Browse files
committed
[ci skip] add note for individual stub creation
1 parent 4d4d764 commit a413111

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

guides/source/testing.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ create test/fixtures/articles.yml
178178
...
179179
```
180180

181+
You can also generate the test stub for a model using the following command:
182+
183+
```bash
184+
$ bin/rails generate test_unit:model article title:string body:text
185+
create test/models/article_test.rb
186+
create test/fixtures/articles.yml
187+
```
188+
181189
The default test stub in `test/models/article_test.rb` looks like this:
182190

183191
```ruby
@@ -509,6 +517,14 @@ You should test for things such as:
509517
510518
Now that we have used Rails scaffold generator for our `Article` resource, it has already created the controller code and tests. You can take look at the file `articles_controller_test.rb` in the `test/controllers` directory.
511519
520+
The following command will generate a controller test case with a filled up
521+
test for each of the seven default actions.
522+
523+
```bash
524+
$ bin/rails generate test_unit:scaffold article
525+
create test/controllers/articles_controller_test.rb
526+
```
527+
512528
Let me take you through one such test, `test_should_get_index` from the file `articles_controller_test.rb`.
513529
514530
```ruby

0 commit comments

Comments
 (0)