On 17/10/06, <b class="gmail_sendername">Bryan Helmkamp</b> <<a href="mailto:bhelmkamp@gmail.com">bhelmkamp@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm having difficulty setting up mocks such that I can verify that<br>Rails was going to render the right template file (for example<br>new.rhtml) and stop Rails from performing the actual rendering.<br><br>After peeking at Rails' internals, I tried two techniques as illustrated here:
<br><br><a href="http://pastie.caboo.se/18197">http://pastie.caboo.se/18197</a><br><br>Neither worked.<br><br>I think the first one failed because Rails doesn't setup<br>response.template to be an instance of ActionView::Base until after
<br>the controller processing is called.<br><br>I have no idea what is going on with the second attempt. It's hitting<br>a mock, but I have no idea where that mock is coming from. Logically,<br>it probably is coming from the any_instance magic, but in that case it
<br>should be expecting the render_file call. Thoughts?<br><br>What am I doing wrong in the second case? Is there another way I<br>could mock this?<br></blockquote></div><br>Why do you need to get into the Rails internals?
<br><br>I think it would be better to mock a part of the published API e.g. the #render method on @controller.<br><br>Otherwise you are effectively testing Rails itself.<br clear="all"><br>-- <br>James.<br><a href="http://blog.floehopper.org">
http://blog.floehopper.org</a>