[rspec-users] locals in partials

Jonathan Linowes jonathan at parkerhill.com
Fri Oct 12 12:47:49 EDT 2007


that works for you?
I'm basically doing the same thing but the

   render "/pages/_page_menu.html.erb", :locals => { :pages => @foo }

produces error

	undefined local variable or method `pages' for #<ActionView::Base: 
0x33a1f6c>

but it works when i add to the top of the partial:

	<%# pages ||= @foo #kludge for rspec %>
	

On Oct 12, 2007, at 11:51 AM, Hans de Graaff wrote:

> On Fri, 2007-10-12 at 10:33 -0400, Jonathan Linowes wrote:
>> hiya, in specing a partial, how can i assign a local var that is
>> normally passed via :locals ? i tried adding :locals => to the render
>> call but that doesnt seem to take
>
> it 'should include :var'
>   render :partial => 'your/partial', :locals => {:var => 'value'}
>   response.should ...
> end
>
> Something like that should work. Otherwise, please post your code,
> that'll make it a lot easier to help out.
>
> Kind regards,
>
> Hans
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list