Re: [rspec-users] RSpec view test for :partial with :locals?
On Wed, Mar 12, 2008 at 3:19 AM, David Schmidt [EMAIL PROTECTED] wrote: I'm currently working on some RSpec view tests and I'm having problems with expect_render. Most of the expect_render's work fine, but in one of my views I have: %= render :partial = user_cloud, :locals = {:user = @featured_user} % I see that expect_render supports :object or :collection for the second parameter, but this partial uses :locals. I tried expect_render without the second parameter and with :locals and it failed to match both times. I confirmed that the partial is rendering in the test.log. Is there a way to match this render? Sounds like a missing feature. Please enter a ticket at http://rspec.lighthouseapp.com. On a similar note, is there a way to test that layout views are rendered? Not in view specs. Layouts are rendered by controllers, not by the views themselves, so you should do that in controller specs. Cheers, David I can test that the :partials in the layout are rendered, but not the layout file itself. In both of these cases I know I could do a has_tag and test for something inside the layout file or partial, but I'd rather test contents in a view test for each partial and just verify that the partial is rendered in the view tests that render the partial. Thank you, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] RSpec view test for :partial with :locals?
Are you assigning @featured_user (ie: assigns[:featured_user]) before you render your template? We use :locals w/o any problem, for example: template.expect_render(:partial = 'profiles/data', :locals = {:profile = @profile}).and_return(%|p id='profiles_data_partial' /|) Zach On Tue, Mar 11, 2008 at 11:19 PM, David Schmidt [EMAIL PROTECTED] wrote: I'm currently working on some RSpec view tests and I'm having problems with expect_render. Most of the expect_render's work fine, but in one of my views I have: %= render :partial = user_cloud, :locals = {:user = @featured_user} % I see that expect_render supports :object or :collection for the second parameter, but this partial uses :locals. I tried expect_render without the second parameter and with :locals and it failed to match both times. I confirmed that the partial is rendering in the test.log. Is there a way to match this render? On a similar note, is there a way to test that layout views are rendered? I can test that the :partials in the layout are rendered, but not the layout file itself. In both of these cases I know I could do a has_tag and test for something inside the layout file or partial, but I'd rather test contents in a view test for each partial and just verify that the partial is rendered in the view tests that render the partial. Thank you, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- Zach Dennis http://www.continuousthinking.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] RSpec view test for :partial with :locals?
I'm currently working on some RSpec view tests and I'm having problems with expect_render. Most of the expect_render's work fine, but in one of my views I have: %= render :partial = user_cloud, :locals = {:user = @featured_user} % I see that expect_render supports :object or :collection for the second parameter, but this partial uses :locals. I tried expect_render without the second parameter and with :locals and it failed to match both times. I confirmed that the partial is rendering in the test.log. Is there a way to match this render? On a similar note, is there a way to test that layout views are rendered? I can test that the :partials in the layout are rendered, but not the layout file itself. In both of these cases I know I could do a has_tag and test for something inside the layout file or partial, but I'd rather test contents in a view test for each partial and just verify that the partial is rendered in the view tests that render the partial. Thank you, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users