<div><br></div><font color="#990099">-----rspec-users-bounces@rubyforge.org wrote: -----<br><br></font>&gt;To:&nbsp;rspec-users&nbsp;&lt;rspec-users@rubyforge.org&gt;<br>&gt;From:&nbsp;"David&nbsp;Chelimsky"&nbsp;&lt;dchelimsky@gmail.com&gt;<br>&gt;Sent&nbsp;by:&nbsp;rspec-users-bounces@rubyforge.org<br>&gt;Date:&nbsp;06/22/2007&nbsp;09:54AM<br>&gt;Subject: Re: [rspec-users] Problems translating should_render from<br>&gt;0.8.2&nbsp;to        1.0.5<br>&gt;<br>&gt;On&nbsp;6/19/07,&nbsp;Jake&nbsp;Scruggs&nbsp;&lt;JScruggs@thoughtworks.com&gt;&nbsp;wrote:<br>&gt;&gt; I'm working on a large Rails site and we want to move from RSpec<br>&gt;0.8.2&nbsp;to<br>&gt;&gt; the latest and greatest. &nbsp;So we ran the translator and yet we're<br>&gt;having&nbsp;a<br>&gt;&gt;&nbsp;lot&nbsp;of&nbsp;trouble&nbsp;translating&nbsp;should_render.<br>&gt;&gt;<br>&gt;&gt;&nbsp;I&nbsp;found&nbsp;this&nbsp;on&nbsp;the&nbsp;web:<br>&gt;&gt;<br>&gt;&gt;&nbsp;We&nbsp;will&nbsp;NOT&nbsp;be&nbsp;supporting&nbsp;the&nbsp;following&nbsp;in&nbsp;the&nbsp;new&nbsp;syntax:<br>&gt;&gt;&nbsp;&nbsp;&nbsp;controller.should_render<br>&gt;&gt;&nbsp;&nbsp;&nbsp;controller.should_redirect_to<br>&gt;&gt;<br>&gt;&gt;&nbsp;You&nbsp;will&nbsp;be&nbsp;able&nbsp;to&nbsp;use&nbsp;instead:<br>&gt;&gt;&nbsp;&nbsp;&nbsp;response.should&nbsp;render_template<br>&gt;&gt;&nbsp;&nbsp;&nbsp;response.should&nbsp;render_text<br>&gt;&gt;&nbsp;&nbsp;&nbsp;response.should&nbsp;redirect_to<br>&gt;&gt;<br>&gt;&gt;&nbsp;But&nbsp;the&nbsp;problem&nbsp;I&nbsp;have&nbsp;is&nbsp;that&nbsp;render_template&nbsp;doesn't&nbsp;have&nbsp;the<br>&gt;&gt; functionality that we used in lots of our should_render<br>&gt;expectations.&nbsp;&nbsp;A&nbsp;lot<br>&gt;&gt; of our should renders specify an action and and a controller, so<br>&gt;now&nbsp;the<br>&gt;&gt; change over is slow (we have to figure out which file is being<br>&gt;rendered<br>&gt;&gt; instead), but the big problem is that when testing actions that<br>&gt;render&nbsp;a<br>&gt;&gt; partial (mostly for ajax calls) we need to test the locals that get<br>&gt;passed<br>&gt;&gt;&nbsp;into&nbsp;the&nbsp;template.<br>&gt;&gt;<br>&gt;&gt;&nbsp;here's&nbsp;a&nbsp;typical&nbsp;spec:<br>&gt;&gt;&nbsp;&nbsp;&nbsp;specify&nbsp;"the&nbsp;:start_date&nbsp;should&nbsp;equal&nbsp;the&nbsp;date&nbsp;passed&nbsp;in"&nbsp;do<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@mock_event_calendar_data&nbsp;=&nbsp;mock('Mock&nbsp;event_calendar_data')<br>&gt;&gt;<br>&gt;&gt;<br>&gt;EventCalendarData.should_receive(:new).and_return(@mock_event_calenda<br>&gt;r_data)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;date&nbsp;=&nbsp;Date.today<br>&gt;&gt; &nbsp; &nbsp; controller.should_render :partial =&gt; 'calendar', :locals =&gt;<br>&gt;{:start_date<br>&gt;&gt;&nbsp;=&gt;&nbsp;date,&nbsp;:event_calendar_data&nbsp;=&gt;&nbsp;@mock_event_calendar_data}<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get&nbsp;'ajax_calendar',&nbsp;:date&nbsp;=&gt;&nbsp;Date.today.strftime("%B-%d-%Y")<br>&gt;&gt;&nbsp;&nbsp;&nbsp;end<br>&gt;&gt;<br>&gt;&gt;&nbsp;here's&nbsp;another&nbsp;expectation&nbsp;I&nbsp;don't&nbsp;know&nbsp;how&nbsp;to&nbsp;translate:<br>&gt;&gt; controller.should_render({:controller=&gt;:content_item,<br>&gt;:layout=&gt;"frame",<br>&gt;&gt;&nbsp;:action=&gt;:upload_image})<br>&gt;&gt;<br>&gt;&gt; Does anybody have any ideas about how to get these things working<br>&gt;in&nbsp;the&nbsp;new<br>&gt;&gt;&nbsp;RSpec?<br>&gt;<br>&gt;Sorry for not responding sooner. This was functionality we yanked<br>&gt;when<br>&gt;we&nbsp;went&nbsp;from&nbsp;should_render&nbsp;to&nbsp;should&nbsp;render_template.&nbsp;To&nbsp;keep&nbsp;the<br>&gt;matchers&nbsp;simple,&nbsp;I'd&nbsp;suggest&nbsp;we&nbsp;add&nbsp;another&nbsp;matcher&nbsp;named<br>&gt;render_action&nbsp;that&nbsp;looked&nbsp;at&nbsp;the&nbsp;hash,&nbsp;or&nbsp;render_with_options.&nbsp;WDYT?<br><br>That would be cool, because right now we have a lot of tests/specs/examples that do things just like the examples I gave and the time involved in converting all these of them means that we probably won't leave RSpec 0.82&nbsp; anytime soon (if at all).&nbsp; If there was a render_action, then the conversion would be more of a simple mapping and might only take a day -- and I'm pretty sure I could&nbsp; convince the business to  give up a day.<br><br>maybe we could pair on it?,<br>-Jake Scruggs<br>