aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2015-07-15 15:55:23 +0200
committerRobin Dupret <robin.dupret@gmail.com>2015-07-15 15:55:23 +0200
commita0b4dc21a2188a4379bc401b73336608fec56c64 (patch)
treebf2de1a0229b6131bc12965b212f379422f205c5 /guides/source
parent4d4d764ab688af4a0d213ab2d0dc7f9b811ab451 (diff)
parenta413111c18ae076f9b14d8c379420eb450ce9a70 (diff)
downloadrails-a0b4dc21a2188a4379bc401b73336608fec56c64.tar.gz
rails-a0b4dc21a2188a4379bc401b73336608fec56c64.tar.bz2
rails-a0b4dc21a2188a4379bc401b73336608fec56c64.zip
Merge pull request #20812 from aditya-kapoor/close-20694
[ci skip] add note for individual stub creation
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/testing.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 2fd54a48fc..d146df3dc6 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -178,6 +178,14 @@ create test/fixtures/articles.yml
...
```
+You can also generate the test stub for a model using the following command:
+
+```bash
+$ bin/rails generate test_unit:model article title:string body:text
+create test/models/article_test.rb
+create test/fixtures/articles.yml
+```
+
The default test stub in `test/models/article_test.rb` looks like this:
```ruby
@@ -509,6 +517,14 @@ You should test for things such as:
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.
+The following command will generate a controller test case with a filled up
+test for each of the seven default actions.
+
+```bash
+$ bin/rails generate test_unit:scaffold article
+create test/controllers/articles_controller_test.rb
+```
+
Let me take you through one such test, `test_should_get_index` from the file `articles_controller_test.rb`.
```ruby