我有一个模型 group.rb,然后是一个无模型的控制器 group_invitations.rb。
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 来测试这个无模式控制器?谢谢