From 062988efd31a0588b07a45d633ea6a8f46c884a6 Mon Sep 17 00:00:00 2001 From: Sandip Ransing Date: Fri, 14 Nov 2014 00:35:51 +0530 Subject: [ci skip] Add one more example to routing testing, and highlight association name keywords --- guides/source/testing.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'guides/source/testing.md') 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 ``` -- cgit v1.2.3