13

ログインしていないユーザーがこのようにどのように動作するかをテストしようとしています

  describe "not logged in user" do
   user_no_rights

    it "can't access action index" do
      expect(get :index).to raise_error(CanCan::AccessDenied)
    end
  end

rspec を実行したときの出力

  Failure/Error: expect(get :index).to raise_error("CanCan::AccessDenied:You are not authorized to access this page.")
     CanCan::AccessDenied:
       You are not authorized to access this page.

正しい execption が発生しているように見えますが、なぜ仕様が通らないのでしょうか?

4

1 に答える 1