0
我有一個model.rb模型,然後是一個無模式的控制器group_invitations.rb。如何爲無模式控制器編寫CanCan rspec?
GroupInvitationsController
before_filter :find_group_by_group_id
before_filter :authenticate_user!
before_filter :current_ability
authorize_resource :class => false
def current_ability
@current_ability ||= Ability.new(current_user, @group)
end
當我寫這個RSpec的:
it "should be able to create" do
ability = Ability.new(nil)
ability.should be_able_to(:create, GroupInvitation.new)
end
RSpec的則有錯誤:
NameError: 未初始化的常量GroupInvitation
如何設置RSpec的測試這種無模式控制器?謝謝