[rspec-users] assign local variable instead of instance variable.

Mathias Stjernström mathias at globalinn.com
Wed Aug 29 08:35:03 EDT 2007


I have a view that generates a list of adverts with <%=  
render :partial => 'advert', :collection => @adverts %>

I have the render call described with  
@controller.template.should_receive(:render).with(:partial =>  
'advert', :collection => @adverts)

Bu when i was about to describe my partial i got stuck.

My partial _advert.rhtml:

<div id="advert_<%= advert.id %>">
	<h3><%=h advert.title %></h3>
	<p><%=h advert.description %></p>

And to describe that: http://pastie.textmate.org/91995

The problem is that (assigns[:advert] = advert) creates an instance  
variable and :collection => @adverts creates a local variable called  

Is there a way of assigning a local variables in a view/template from  
my description/spec?


Mathias Stjernstrom

More information about the rspec-users mailing list