title: Rspec controller error? expecting <"index"> but rendering with <""> or it's working?
body: <p>I'm new with rspec test and maybe there are something that I dont undertand.</p>
  
  <p>if can any help me, I really appreciate some help. </p>
  
  <p>File Structure:</p>
  
  <pre><code>app/models/booking.rb
  app/models/user.rb
  app/models/role.rb
  app/models/ability.rb   
  
  app/controllers/bookings_controller.rb
  
  app/views/bookings/index.html.erb
  app/views/dashboard/index.html.erb
  
  app/spec/controllers/bookings_controller_spec.rb
  </code></pre>
  
  <p>I read this link with a similar problem but it isn't solved</p>
  
  <p><a href="https://stackoverflow.com/questions/13075972/rspec-controller-error-expecting-index-but-rendering-with">Rspec controller error expecting &lt;&quot;index&quot;&gt; but rendering with &lt;&quot;&quot;&gt;</a></p>
  
  <p>is similar, because if I change this line:</p>
  
  <pre><code>    it 'should not render index template from bookings' do
          get :index
  =&gt;      response.should_not render_template(:index)
      end
  </code></pre>
  
  <p>for this other:</p>
  
  <pre><code>    it 'should not render index template from bookings' do
          get :index
  =&gt;      response.should render_template(:index)
      end
  </code></pre>
  
  <p>I get the same mistake that in the link </p>
  
  <p>expecting &lt;"index"> but rendering with &lt;""></p>
  
  <p>and I don't know why?
  Here's my Code:</p>
  
  <p>My Spec:</p>
  
  <pre><code>describe BookingsController do
  context 'as guest' do
    before(:each) do
      @user = User.new(:email =&gt; 'mail_admin@test.com',
                  :username =&gt; 'admin',
                  :password =&gt; 'password_admin',
                  :password_confirmation =&gt; 'password_admin')
      @user.save
      #when i save, with gem CanCan i assign a default role to @user
      #with the default role the user only can see the views/dashboard/index.html.erb
    end
  
    it 'should not render index template from bookings' do
      get :index
      response.should_not render_template(:index)
    end
  end  
  end
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class BookingsController &lt; ApplicationController
  load_and_authorize_resource
  
   def index
    ...      
   end
  
   def show
    ...
   end
  end
  </code></pre>
  
  <p>My model:</p>
  
  <pre><code>class Booking &lt; Activerecord::Base
  paginates_per 20
  
   def 
    ...      
   end
  
   def 
    ...
   end
  end
  </code></pre>
  
  <p>User:</p>
  
  <pre><code>Class User &lt; ActiveRecord::Base
    after_save :set_default_role
    rolify
    .
    .
    .
    .
    def set_default_role
     self.add_role :default
    end
  end
  </code></pre>
  
  <p>Role:</p>
  
  <pre><code>class Role &lt; ActiveRecord::Base
   ROLES = {"admin" =&gt; "Admin", "default" =&gt; "Default"}
   .
   .
   .
   . 
   scopify
  end
  </code></pre>
  
  <p>Ability:</p>
  
  <pre><code>class Ability
    include CanCan::Ability
  
    def initialize(user)
    user ||= User.new
    if user.has_role? :admin
     can :manage, :all
    elsif user.has_role? :data_consistency
     can :read, Booking
    end
   end
  end
  </code></pre>