Flowdock
method

assert_template

Importance_3
Ruby on Rails latest stable (v6.1.7.7) - 2 notes - Class: ActionController::Assertions::ResponseAssertions

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

These similar methods exist in v6.1.7.7:

assert_template(options = {}, message = nil) public

Asserts that the request was rendered with the appropriate template file or partials

Examples

  # assert that the "new" view template was rendered
  assert_template "new"

  # assert that the "new" view template was rendered with Symbol
  assert_template :new

  # assert that the "_customer" partial was rendered twice
  assert_template :partial => '_customer', :count => 2

  # assert that no partials were rendered
  assert_template :partial => false
Show source
Register or log in to add new notes.
February 1, 2009 - (v2.2.1)
3 thanks

You can't use Symbols, but you can use Regexps

You can’t use Symbol (although Symbol is accepted with render :action => :new), like:

assert_template :new # WON'T WORK!

But you can use Regexp, e.g.:

assert_template /new/ # WORKS OK

Note that the String matched with your Regexp is the full path to the template relative to the view/ directory of your app, so this will not work:

assert_template /^new$/ # WON'T WORK!

However this might:

assert_template /^employees\/new.html.haml$/