method
assert_template
v2.1.0 -
Show latest stable
-
2 notes -
Class: ActionController::Assertions::ResponseAssertions
- 1.0.0
- 1.1.6
- 1.2.6 (0)
- 2.0.3 (8)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (24)
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
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"
Register or
log in
to add new notes.
szeryf -
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$/
hardbap -
November 4, 2009
1 thank
As of v2.3.4 you can use Symbols
This commit fixes using a Symbol with assert_template
http://github.com/rails/rails/commit/f383a4aa333cd8a99003eb1bdbb27b6fdea1056c
assert_template :new # works in 2.3.4