[rspec-users] Testing Views with Authentication

Pat Maddox pergesu at gmail.com
Wed Oct 8 20:22:08 EDT 2008


Donald French <dhf0820 at gmail.com> writes:

> I am trying to figure out how to properly test a view when part of the
> view is is protected with a role check <% if current_user.admin? %>..
> How do I force a log in or mock the current user. I need to do it in a
> DRY way as this is used throughout the system checking various
> privileges.
>
> Don French
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

You can stub the template object:
  template.stub!(:current_user).and_return mock_admin
  
Pat


More information about the rspec-users mailing list