I’m currently working on some RSpec view tests and I’m having problems
with expect_render. Most of the expect_render’s work fine, but in one
of my views I have:
<%= render :partial => “user_cloud”, :locals => {:user =>
@featured_user} %>
I see that expect_render supports “:object” or “:collection” for the
second parameter, but this partial uses “:locals”. I tried
expect_render without the second parameter and with “:locals” and it
failed to match both times. I confirmed that the partial is rendering
in the test.log. Is there a way to match this render?
On a similar note, is there a way to test that layout views are
rendered? I can test that the :partials in the layout are rendered,
but not the layout file itself.
In both of these cases I know I could do a “has_tag” and test for
something inside the layout file or partial, but I’d rather test
contents in a view test for each partial and just verify that the
partial is rendered in the view tests that render the partial.
Thank you,
David