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 linoj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071012/fd0acd92/attachment.html
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 takeit ''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 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071012/05b2fd27/attachment.bin
Hi Jon,
I was having trouble with partials a while ago and I think it might have
info on solving your problem
http://www.nabble.com/spec%27ing-view-render-partial-collection%2C-local-variable-not-found-tf4577761.html
I''m guessing your referring to when you called your parital in a spec:
it "should show game name" do
render :partial =>"games/game", :locals => {:game =>
@game}
response.should have_tag(''h3'', /The Battle for Blaze/)
end
You need to provide a bit more information about your specs such as code and
reported error.
On 10/12/07, Jonathan Linowes <jonathan at parkerhill.com>
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
>
> linoj
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
--
Monsterbox Productions
putting small businesses on-line
1319 Victoria Avenue East
Thunder Bay, Ontario P7C 1C3
Canada
Andrew WC Brown
web-developer and owner
andrew at monsterboxpro.com
P: 807-626-9009
F: 807-624-2705
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/rspec-users/attachments/20071012/b78d23f9/attachment.html
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
oops, of course that last line wouldnt be commented out On Oct 12, 2007, at 12:47 PM, Jonathan Linowes wrote:> > 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 >
On Fri, 2007-10-12 at 12:47 -0400, Jonathan Linowes wrote:> that works for you? > I''m basically doing the same thing but the > > render "/pages/_page_menu.html.erb", :locals => { :pages => @foo }render :partial => ''pages/page_menu'', :locals => {:pages => @foo} Note the :partial. Kind regards, Hans -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071012/0d43e8b3/attachment.bin
On 10/12/07, Hans de Graaff <hans at degraaff.org> wrote:> On Fri, 2007-10-12 at 12:47 -0400, Jonathan Linowes wrote: > > that works for you? > > I''m basically doing the same thing but the > > > > render "/pages/_page_menu.html.erb", :locals => { :pages => @foo } > > render :partial => ''pages/page_menu'', :locals => {:pages => @foo} > > Note the :partial.Yes - that''s correct. The render method in view specs delegates to rails'' render method, but allows you to skip the :template key in the hash as a convenience: render ''/path/to/template'' If you don''t specify what ''/path/to/template'' represents, it is passed like this: controller.render :template => ''/path/to/template'' So if you add additional pairs to the hash, they just get passed to AC::Base, which only deals with :locals, :object and :collection if you specify that you''re using a partial. Cheers, David> > Kind regards, > > Hans > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >