This project is archived and is in readonly mode.
a :partial option in assert_template
Reported by dust | December 10th, 2008 @ 08:20 PM | in 2.x
In one app I work on I have to spend a fair amount of test code
ensuring that partials are rendered (or not) depending on user
permissions and what data exists and so on and so forth. Until now
I've just been writing helpers named tag_list_rendered
and bookmark_toggle_rendered
and such, all of which
liberally use assert_select
to divine if the output I
want is there.
Right below all those helpers were
assert_template
s, and I realized just how more
readable assert_template :partial =>
'shared/_bookmark_toggle'
would be than assert
bookmark_toggle_rendered
. So with this patch you can now
do:
assert_template 'index'
and assert_template
nil
like you can now.
assert_template :partial => '_name'
to assert if
it was rendered
assert_template :partial => '_name', :count =>
14
to assert it was rendered a specific number of times
assert_template :partial => '_name', :count =>
0
to assert that given partial was not rendered
assert_template :partial => false
to assert that
no partials were rendered.
Comments and changes to this ticket
-
josh December 11th, 2008 @ 12:48 AM
- Assigned user set to josh
I'm down for adding support for this, but I have a few concerns.
I'm mainly worried about performance. Tracking these counts hurts a little bit. And this data is only going to be used in tests. So your production env is still doing all this work and throwing it away.
My ideal solution would be to monkey patch the render method when we start a testing env so it wouldn't affect production performance at all.
Also, I really hate @_first_render, if you can knock that out too, that would be awesome.
-
dust December 11th, 2008 @ 02:45 PM
Alrighty, it now patches the tracking stuff in when actionview's test setup stuff is loaded.
-
Repository December 11th, 2008 @ 05:07 PM
- State changed from new to resolved
(from [49306ccacf01e36d444771d42321965616e226f0]) Add :partial option to assert_template [#1550 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
-
Jeff Kreeftmeijer November 7th, 2010 @ 04:55 PM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1550 a :partial option in assert_template (from [49306ccacf01e36d444771d42321965616e226f0]) Add :pa...