> And why wouldn't you want to test that?
>
I want to test for it, it's just that I don't want to copy/paste spec
like an idiot.
> def for_roles *roles
> roles.each do |role|
> before(:each) { login_as role }
> yield
> end
> end
>
> describe OrdersController do
> describe "GET index" do
> for_roles :admin, :sysadmin do |role|
> it "..." do ... end
> end
> for_roles :sysadmin do |role|
> it "..." do ... end
> end
> end
> This scheme makes it easy when we decide to remove a privilege from
> admin but keep it in sysadmin. Just move that example (it "...") to
> the other for_roles block.
>
> WDYT?
I like your idea very much, very clean, readable and maintainable.
And thank you Mark, I will also use your idea to factor out
commonalities in my specs.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users