v2.3.8 - Show latest stable - 2 notes - Class: ActionController::Assertions::ResponseAssertions
assert_template(options = {}, message = nil) public

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


  # 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$/