Jake Scruggs
2007-Jun-19 14:30 UTC
[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5
<font size="2">I''m working on a large Rails site and we want to move from RSpec 0.8.2 to the latest and greatest. So we ran the translator and yet we''re having a lot of trouble translating should_render.<br><br>I found this on the web:<br><br>We will NOT be supporting the following in the new syntax:<br> controller.should_render<br> controller.should_redirect_to<br><br>You will be able to use instead:<br> response.should render_template<br> response.should render_text<br> response.should redirect_to<br><br>But the problem I have is that render_template doesn''t have the functionality that we used in lots of our should_render expectations. A lot of our should renders specify an action and and a controller, so now the change over is slow (we have to figure out which file is being rendered instead), but the big problem is that when testing actions that render a partial (mostly for ajax calls) we need to test the locals that get passed into the template.<br><br>here''s a typical spec:<br> specify "the :start_date should equal the date passed in" do<br> @mock_event_calendar_data = mock(''Mock event_calendar_data'')<br> EventCalendarData.should_receive(:new).and_return(@mock_event_calendar_data)<br> date = Date.today<br> controller.should_render :partial => ''calendar'', :locals => {:start_date => date, :event_calendar_data => @mock_event_calendar_data}<br> get ''ajax_calendar'', :date => Date.today.strftime("%B-%d-%Y")<br> end<br><br>here''s another expectation I don''t know how to translate:<br>controller.should_render({:controller=>:content_item, :layout=>"frame", :action=>:upload_image})<br><br>Does anybody have any ideas about how to get these things working in the new RSpec?<br><br>Thanks for your help,<br>-Jake Scruggs<br></font>
Courtenay
2007-Jun-19 20:26 UTC
[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5
On 6/19/07, Jake Scruggs <JScruggs at thoughtworks.com> wrote:> I''m working on a large Rails site and we want to move from RSpec 0.8.2 to > the latest and greatest. So we ran the translator and yet we''re having a > lot of trouble translating should_render. > > I found this on the web: > > We will NOT be supporting the following in the new syntax: > controller.should_render > controller.should_redirect_to > > You will be able to use instead: > response.should render_template > response.should render_text > response.should redirect_to > > But the problem I have is that render_template doesn''t have the > functionality that we used in lots of our should_render expectations. A lot > of our should renders specify an action and and a controller, so now the > change over is slow (we have to figure out which file is being rendered > instead), but the big problem is that when testing actions that render a > partial (mostly for ajax calls) we need to test the locals that get passed > into the template. > > here''s a typical spec: > specify "the :start_date should equal the date passed in" do > @mock_event_calendar_data = mock(''Mock event_calendar_data'') > > EventCalendarData.should_receive(:new).and_return(@mock_event_calendar_data) > date = Date.today > controller.should_render :partial => ''calendar'', :locals => {:start_date > => date, :event_calendar_data => @mock_event_calendar_data} > get ''ajax_calendar'', :date => Date.today.strftime("%B-%d-%Y") > endfirst, move the should_render to AFTER the get call.
David Chelimsky
2007-Jun-22 14:54 UTC
[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5
On 6/19/07, Jake Scruggs <JScruggs at thoughtworks.com> wrote:> I''m working on a large Rails site and we want to move from RSpec 0.8.2 to > the latest and greatest. So we ran the translator and yet we''re having a > lot of trouble translating should_render. > > I found this on the web: > > We will NOT be supporting the following in the new syntax: > controller.should_render > controller.should_redirect_to > > You will be able to use instead: > response.should render_template > response.should render_text > response.should redirect_to > > But the problem I have is that render_template doesn''t have the > functionality that we used in lots of our should_render expectations. A lot > of our should renders specify an action and and a controller, so now the > change over is slow (we have to figure out which file is being rendered > instead), but the big problem is that when testing actions that render a > partial (mostly for ajax calls) we need to test the locals that get passed > into the template. > > here''s a typical spec: > specify "the :start_date should equal the date passed in" do > @mock_event_calendar_data = mock(''Mock event_calendar_data'') > > EventCalendarData.should_receive(:new).and_return(@mock_event_calendar_data) > date = Date.today > controller.should_render :partial => ''calendar'', :locals => {:start_date > => date, :event_calendar_data => @mock_event_calendar_data} > get ''ajax_calendar'', :date => Date.today.strftime("%B-%d-%Y") > end > > here''s another expectation I don''t know how to translate: > controller.should_render({:controller=>:content_item, :layout=>"frame", > :action=>:upload_image}) > > Does anybody have any ideas about how to get these things working in the new > RSpec?Sorry for not responding sooner. This was functionality we yanked when we went from should_render to should render_template. To keep the matchers simple, I''d suggest we add another matcher named render_action that looked at the hash, or render_with_options. WDYT?
Jake Scruggs
2007-Jun-26 16:17 UTC
[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5
<div><br></div><font color="#990099">-----rspec-users-bounces@rubyforge.org wrote: -----<br><br></font>>To: rspec-users <rspec-users@rubyforge.org><br>>From: "David Chelimsky" <dchelimsky@gmail.com><br>>Sent by: rspec-users-bounces@rubyforge.org<br>>Date: 06/22/2007 09:54AM<br>>Subject: Re: [rspec-users] Problems translating should_render from<br>>0.8.2 to        1.0.5<br>><br>>On 6/19/07, Jake Scruggs <JScruggs@thoughtworks.com> wrote:<br>>> I''m working on a large Rails site and we want to move from RSpec<br>>0.8.2 to<br>>> the latest and greatest. So we ran the translator and yet we''re<br>>having a<br>>> lot of trouble translating should_render.<br>>><br>>> I found this on the web:<br>>><br>>> We will NOT be supporting the following in the new syntax:<br>>> controller.should_render<br>>> controller.should_redirect_to<br>>><br>>> You will be able to use instead:<br>>> response.should render_template<br>>> response.should render_text<br>>> response.should redirect_to<br>>><br>>> But the problem I have is that render_template doesn''t have the<br>>> functionality that we used in lots of our should_render<br>>expectations. A lot<br>>> of our should renders specify an action and and a controller, so<br>>now the<br>>> change over is slow (we have to figure out which file is being<br>>rendered<br>>> instead), but the big problem is that when testing actions that<br>>render a<br>>> partial (mostly for ajax calls) we need to test the locals that get<br>>passed<br>>> into the template.<br>>><br>>> here''s a typical spec:<br>>> specify "the :start_date should equal the date passed in" do<br>>> @mock_event_calendar_data = mock(''Mock event_calendar_data'')<br>>><br>>><br>>EventCalendarData.should_receive(:new).and_return(@mock_event_calenda<br>>r_data)<br>>> date = Date.today<br>>> controller.should_render :partial => ''calendar'', :locals =><br>>{:start_date<br>>> => date, :event_calendar_data => @mock_event_calendar_data}<br>>> get ''ajax_calendar'', :date => Date.today.strftime("%B-%d-%Y")<br>>> end<br>>><br>>> here''s another expectation I don''t know how to translate:<br>>> controller.should_render({:controller=>:content_item,<br>>:layout=>"frame",<br>>> :action=>:upload_image})<br>>><br>>> Does anybody have any ideas about how to get these things working<br>>in the new<br>>> RSpec?<br>><br>>Sorry for not responding sooner. This was functionality we yanked<br>>when<br>>we went from should_render to should render_template. To keep the<br>>matchers simple, I''d suggest we add another matcher named<br>>render_action that looked at the hash, or render_with_options. 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 anytime soon (if at all). 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 convince the business to give up a day.<br><br>maybe we could pair on it?,<br>-Jake Scruggs<br>
David Chelimsky
2007-Jun-27 01:19 UTC
[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5
On 6/26/07, Jake Scruggs <JScruggs at thoughtworks.com> wrote:> > -----rspec-users-bounces at rubyforge.org wrote: ----- > > >To: rspec-users <rspec-users at rubyforge.org> > >From: "David Chelimsky" <dchelimsky at gmail.com> > >Sent by: rspec-users-bounces at rubyforge.org > >Date: 06/22/2007 09:54AM > >Subject: Re: [rspec-users] Problems translating should_render from > >0.8.2 to 1.0.5 > > > > >On 6/19/07, Jake Scruggs <JScruggs at thoughtworks.com> wrote: > >> I''m working on a large Rails site and we want to move from RSpec > >0.8.2 to > >> the latest and greatest. So we ran the translator and yet we''re > >having a > >> lot of trouble translating should_render. > >> > >> I found this on the web: > >> > >> We will NOT be supporting the following in the > new syntax: > >> controller.should_render > >> controller.should_redirect_to > >> > >> You will be able to use instead: > >> response.should render_template > >> response.should render_text > >> response.should redirect_to > >> > >> But the problem I have is that render_template > doesn''t have the > >> functionality that we used in lots of our should_render > >expectations. A lot > >> of our should renders specify an action and and a controller, so > >now the > >> change over is slow (we have to figure out which file is being > >rendered > >> instead), but the big problem is that when testing actions that > >render a > >> partial (mostly for ajax calls) we need to test the locals that get > >passed > >> into the template. > >> > >> here''s a typical spec: > >> specify "the :start_date should equal the date > passed in" do > >> @mock_event_calendar_data = mock(''Mock > event_calendar_data'') > >> > >> > >EventCalendarData.should_receive(:new).and_return(@mock_event_calenda > >r_data) > >> date = Date.today > >> controller.should_render :partial => ''calendar'', :locals => > >{:start_date > >> => date, :event_calendar_data => > @mock_event_calendar_data} > >> get ''ajax_calendar'', :date => > Date.today.strftime("%B-%d-%Y") > >> end > >> > >> here''s another expectation I don''t know how to > translate: > >> controller.should_render({:controller=>:content_item, > >:layout=>"frame", > >> :action=>:upload_image}) > >> > >> Does anybody have any ideas about how to get these things working > >in the new > >> RSpec? > > > >Sorry for not responding sooner. This was functionality we yanked > >when > >we went from should_render to should render_template. > To keep the > >matchers simple, I''d suggest we add another matcher named > >render_action that looked at the hash, or > render_with_options. WDYT? > > 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 > anytime soon (if at all). 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 convince the business to give up a day. > > maybe we could pair on it?,That''d be great!> -Jake Scruggs > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Jun-28 13:09 UTC
[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5
On 6/26/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 6/26/07, Jake Scruggs <JScruggs at thoughtworks.com> wrote: > > > > -----rspec-users-bounces at rubyforge.org wrote: ----- > > > > >To: rspec-users <rspec-users at rubyforge.org> > > >From: "David Chelimsky" <dchelimsky at gmail.com> > > >Sent by: rspec-users-bounces at rubyforge.org > > >Date: 06/22/2007 09:54AM > > >Subject: Re: [rspec-users] Problems translating should_render from > > >0.8.2 to 1.0.5 > > > > > > > >On 6/19/07, Jake Scruggs <JScruggs at thoughtworks.com> wrote: > > >> I''m working on a large Rails site and we want to move from RSpec > > >0.8.2 to > > >> the latest and greatest. So we ran the translator and yet we''re > > >having a > > >> lot of trouble translating should_render. > > >> > > >> I found this on the web: > > >> > > >> We will NOT be supporting the following in the > > new syntax: > > >> controller.should_render > > >> controller.should_redirect_to > > >> > > >> You will be able to use instead: > > >> response.should render_template > > >> response.should render_text > > >> response.should redirect_to > > >> > > >> But the problem I have is that render_template > > doesn''t have the > > >> functionality that we used in lots of our should_render > > >expectations. A lot > > >> of our should renders specify an action and and a controller, so > > >now the > > >> change over is slow (we have to figure out which file is being > > >rendered > > >> instead), but the big problem is that when testing actions that > > >render a > > >> partial (mostly for ajax calls) we need to test the locals that get > > >passed > > >> into the template. > > >> > > >> here''s a typical spec: > > >> specify "the :start_date should equal the date > > passed in" do > > >> @mock_event_calendar_data = mock(''Mock > > event_calendar_data'') > > >> > > >> > > >EventCalendarData.should_receive(:new).and_return(@mock_event_calenda > > >r_data) > > >> date = Date.today > > >> controller.should_render :partial => ''calendar'', :locals => > > >{:start_date > > >> => date, :event_calendar_data => > > @mock_event_calendar_data} > > >> get ''ajax_calendar'', :date => > > Date.today.strftime("%B-%d-%Y") > > >> end > > >> > > >> here''s another expectation I don''t know how to > > translate: > > >> controller.should_render({:controller=>:content_item, > > >:layout=>"frame", > > >> :action=>:upload_image}) > > >> > > >> Does anybody have any ideas about how to get these things working > > >in the new > > >> RSpec? > > > > > >Sorry for not responding sooner. This was functionality we yanked > > >when > > >we went from should_render to should render_template. > > To keep the > > >matchers simple, I''d suggest we add another matcher named > > >render_action that looked at the hash, or > > render_with_options. WDYT? > > > > 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 > > anytime soon (if at all). 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 convince the business to give up a day. > > > > maybe we could pair on it?, > > That''d be great!So Jake came by last night and we paired on this and got it solved. You can read about the solution here: http://blog.davidchelimsky.net/articles/2007/06/28/template-expects_render Cheers, David> > > -Jake Scruggs > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > >