[rspec-users] how to mock/stub restful_authenticated and acl2-ized act

Giuseppe Bertini lists at ruby-forum.com
Tue Apr 8 16:17:02 EDT 2008


Hi Glenn, thanks for the response.

> I would do something like this:
>
> user = mock_model(User, :operator => true)
> controller.stub!(:current_user).and_return(user)

OK, so, :operator is not a User attribute. Rather, a user is an 
operator, so to speak, if a habtm relationship exists between the user 
and the role titled 'operator'. If I modify your code like this:

    role = mock_model(Role, :title => 'operator')
    user = mock_model(User, :roles => [role])
    controller.stub!(:current_user).and_return(user)

things appear to be working well.
Thank you again for your help!

Giuseppe
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list