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

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


Hello,

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>
</div>

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  
advert.

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

Cheers!

Mathias Stjernstrom




More information about the rspec-users mailing list