[rspec-users] Best Practice for Controllers

Ants Pants antsmailinglist at gmail.com
Mon Jan 17 10:48:04 EST 2011

Hello all,

>From what I've seen, this type of question doesn't really seem to get an
answer on this list as most of the replies relate to failures of RSpec. If
this is the case, where is the best place to go to get advice about best
practices etc?

I have a question about best practice. In some of my controllers only an
admin user can perform edit, update, show etc. So I have a before filter in
those controllers; ApplicationController#authorise_is_admin

The ApplicationController#authorise_is_admin throws an AccessDenied
exception and that is caught in ApplicationController#access_denied

My question is, in the spec for the calling controller, let's say
ProductGroups, what should I spec?

I have a context "user is admin" and that's easy to spec, but the context
"user is not admin" is where I'm stuck as no actions are performed in that
controller but I would just like to cover that failure somehow.

Any advice?

Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110117/5c32f33e/attachment-0001.html>

More information about the rspec-users mailing list