method

assert_template

Importance_2
v2.1.0 - Show latest stable - 2 notes - Class: ActionController::Assertions::ResponseAssertions
assert_template(expected = nil, message=nil) public

Asserts that the request was rendered with the appropriate template file.

Examples

  # assert that the "new" view template was rendered
  assert_template "new"
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$/