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

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

Hi Jarkko, I see your point.

However, checking the user's roles in order to authorize access to the 
action is done behind the scenes by the acl_system2 plugin, which would 
not know what to do with has_role?, unless I am missing something.


> You might want to take that one step further and create a method such
> as has_role?(:operator) for the user class. That way you don't have to
> stub arrays  like roles in your specs, you just stub that method to
> return true or false and you're done. That way you make your code more
> easily "speccable":
> def has_role?(role)
>    roles.map(&:title).include?(role.to_s)
> end
> //jarkko
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list