diff options
author | Panayotis Matsinopoulos <panayotis@matsinopoulos.gr> | 2012-03-24 23:33:41 +0200 |
---|---|---|
committer | Panayotis Matsinopoulos <panayotis@matsinopoulos.gr> | 2012-03-24 23:33:41 +0200 |
commit | c12b88695536418f0db33604590d20ff84323ae3 (patch) | |
tree | 665eb970b02f2237981f96f48c7fe0e05215075b | |
parent | 5b35664481bdc4f8c8970a8aade4b460fae1f065 (diff) | |
download | rails-c12b88695536418f0db33604590d20ff84323ae3.tar.gz rails-c12b88695536418f0db33604590d20ff84323ae3.tar.bz2 rails-c12b88695536418f0db33604590d20ff84323ae3.zip |
Testing layout gotcha when view renders partial
-rw-r--r-- | guides/source/testing.textile | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/guides/source/testing.textile b/guides/source/testing.textile index d98082ea88..c1c7b2f341 100644 --- a/guides/source/testing.textile +++ b/guides/source/testing.textile @@ -548,6 +548,22 @@ file in this standard layout directory. Hence, will not work. +<b>Gotcha: Watch out if your view renders any partial</b> + +If your view renders any partial, when asserting for the layout, you have to assert for the partial at the same time. +Otherwise, assertion will fail. + +Hence: + +<ruby> +test "new should render correct layout" do + get :new + assert_template :layout => "layouts/application", :partial => "_form" +end +</ruby> + +is the correct way to assert for the layout when the view renders a partial with name +_form+. Omitting the +:partial+ key in your +assert_template+ call will complain. + h4. A Fuller Functional Test Example Here's another example that uses +flash+, +assert_redirected_to+, and +assert_difference+: |