title: Undefined method index? pundit testing in Rails
body: <p>I am using <code>Pundit</code> for authorization in my application with rspec for testing.</p>
  
  <pre><code>require 'rails_helper'
  
  describe SubjectPolicy do
    subject { described_class.new(user, subject) }
    let(:subject) { Subject.create }
  
    context 'is an administrator' do
      let(:role) { Role.create(role_name: 'admin') }
      let(:user) { User.create(role_id: role.id) }
  
      it { is_expected.to permit_actions([:index]) }
    end
  
    context 'is a teacher' do
      let(:role) { Role.create(role_name: 'teacher') }
      let(:user) { User.create(role_id: role.id) }
  
      it { is_expected.to forbid_actions([:index]) }
    end
  end
  </code></pre>
  
  <p>When running the test for this spec test I receive the following error.</p>
  
  <pre><code>Failure/Error: it { is_expected.to permit_actions([:index]) }
  
  NoMethodError: undefined method 'index?' for #&lt;Subject:0x007fdcc1f70fd0&gt;
  </code></pre>
  
  <p>There is a route for this index action and it is in my <code>subjects_controller</code>. </p>
  
  <p>The code in the subject policy is very simple.</p>
  
  <pre><code>class SubjectPolicy &lt; ApplicationPolicy
    def index?
      @user.is_admin?
    end
  end
  </code></pre>
  
  <p>Here is the index action in my <code>subjects_controller</code></p>
  
  <pre><code>def index
    @subjects = Subject.all
    authorize @subjects
  end
  </code></pre>
  
  <p>I am able to create subjects as an admin, and it does in fact block non-admins from accessing the index. But I am confused as to why this test would fail. I have this policy spec set up just like others and they are passing just fine. Any idea? </p>