RSpec view test for render :partial with :locals?

I was working on some rspec views tests and I've noticed that partial renderization can be tricky.

For example, if we have an index page that renders the objects list in a partial template.

In my case I was testing using a 'GivingClub' list:

describe "giving_clubs" do
  before do
    @giving_clubs = [mock_model(GivingClub)]
    assigns[:giving_clubs] = @giving_clubs
  end

  it "expect render giving clubs list" do
    template.expect_render(:partial => "/giving_clubs/list", :locals => { :giving_clubs => @giving_clubs })
    render "/giving_clubs/index"
  end
end

Do not forget the assigns before call template.expect_render. Locals works fine in this way.