[rspec-users] Problems translating should_render from 0.8.2 to 1.0.5

Courtenay court3nay at gmail.com
Tue Jun 19 16:26:51 EDT 2007

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

first, move the should_render to AFTER the get call.

More information about the rspec-users mailing list