好的,所以我没有编写一大堆访问控制规范,并将它们复制到我的许多规范文件中,而是希望创建一个自定义匹配器。所以代替这个:
describe "access control" do
it "should prevent access by non-logged-in users"
it "should prevent access by normal users"
it "should prevent access by editor users"
it "should prevent access by admin users"
it "should allow access by super admin users"
end
我想做这样的事情:
lambda do
get :index
end.should have_access_control(:allowed => [:super_admin], :disallowed => [:admin, :editor, :user])
有什么例子或建议可以说明我如何去做这样的事情吗?