This project is archived and is in readonly mode.

#1550 ✓resolved
dust

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_templates, 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

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>

Referenced by

Pages