aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/testing.md
diff options
context:
space:
mode:
authorSandip Ransing <sandip@funonrails.com>2014-11-14 00:35:51 +0530
committerZachary Scott <e@zzak.io>2014-11-13 11:50:56 -0800
commit062988efd31a0588b07a45d633ea6a8f46c884a6 (patch)
tree97f5433e5b06253c7ecc964718f0c03e13f74f14 /guides/source/testing.md
parent77ed79b84204f56802b2e9e093d47fd2a7a6ca21 (diff)
downloadrails-062988efd31a0588b07a45d633ea6a8f46c884a6.tar.gz
rails-062988efd31a0588b07a45d633ea6a8f46c884a6.tar.bz2
rails-062988efd31a0588b07a45d633ea6a8f46c884a6.zip
[ci skip] Add one more example to routing testing, and highlight association
name keywords
Diffstat (limited to 'guides/source/testing.md')
-rw-r--r--guides/source/testing.md8
1 files changed, 6 insertions, 2 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index ce815156a7..79e7ac5aef 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -82,7 +82,7 @@ Each fixture is given a name followed by an indented list of colon-separated key
If you are working with [associations](/association_basics.html), you can simply
define a reference node between two different fixtures. Here's an example with
-a belongs_to/has_many association:
+a `belongs_to`/`has_many` association:
```yaml
# In fixtures/categories.yml
@@ -901,13 +901,17 @@ end
Testing Routes
--------------
-Like everything else in your Rails application, it is recommended that you test your routes. An example test for a route in the default `show` action of `Articles` controller above should look like:
+Like everything else in your Rails application, it is recommended that you test your routes. Below are example tests for the routes of default `show` and `create` action of `Articles` controller above and it should look like:
```ruby
class ArticleRoutesTest < ActionController::TestCase
test "should route to article" do
assert_routing '/articles/1', { controller: "articles", action: "show", id: "1" }
end
+
+ test "should route to create article" do
+ assert_routing({ method: 'post', path: '/articles' }, { controller: "articles", action: "create" })
+ end
end
```