[rspec-users] template.expect_render fails when partial is rendered from a helper

J2M james2mccarthy at gmail.com
Thu Aug 14 10:20:18 EDT 2008


Is this expected behaviour?


On Aug 8, 9:46 pm, J2M <james2mccar... at gmail.com> wrote:
> My spec;
>
>   describe 'subnav rendering while logged in' do
>
>     before do
>       template.stub!(:logged_in?).and_return(true)
>       template.stub!
> (:current_profile).at_least(:once).and_return(mock_profile)
>     end
>
>     def do_render
>       render "/homepages/show.html.erb"
>     end
>
>     it "should render the logged in partial for homepages" do
>       template.expect_render(:partial => 'shared/subnav/home', :locals
> => {:active => :home})
>       do_render
>     end
>
>   end
>
> passes if I render the partial directly in the view,
>
> render :partial => 'shared/subnav/home', :locals => {:active => :home}
>
> but it fails if the partial is rendered by a helper;
>
> module ApplicationHelper
>   def subnav(partial, args={})
>     active = args[:active] || :no_highlight
>     if partial == :home
>       partial = (logged_in? ? 'home' : 'login')
>     end
>     render :partial => "shared/subnav/#{partial}", :locals => {:active
> => active}
>   end
> end
>
> Is there any way to check whether the helper renders it?
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list