How to render a partial for test?

Railists:

This snip works inside an index.rhtml.

<%= render :partial => ‘chat/index’,
:locals => { :panel_id => 1 }
%>

Pretend for a moment that I know nothing about Rails. (:slight_smile:

How do I write a test case that renders a partial and puts the result
where goodies like assert_select can get into it?


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

This snip works inside an index.rhtml.

<%= render :partial => ‘chat/index’,
:locals => { :panel_id => 1 }
%>

I now need an answer to a bigger problem. (Apologies for it’s
impossible to Google for, because ‘xml’ will give too many false hits.)

Suppose I wanted to concoct an HTML page using an RXML template,
because the source is so much cleaner and easier to refactor.

When that chat/index is an RXML, something in the rendering system
drops the Content-type: html/text from the outbound rendered contents.

This truly sucks, because I can no longer use “convention over
configuration”. I have to put my XmlMarkup stuff into a function and
call it the old-fashioned way.

Oh, but now it’s easier to test as a partial… :wink:

On 11/21/06, Phlip [email protected] wrote:

How do I write a test case that renders a partial and puts the result
where goodies like assert_select can get into it?

Use Test::Rails, part of ZenTest.

http://zentest.rubyforge.org/ZenTest/

  • rob

http://www.ajaxian.com