title: Rspec controller basic test
body: <p>I'm working on a ruby on rails project (rails 3.2.12 and ruby 1.9.3) and I'm trying to test one of my controllers. So, I have this controller:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
    def index
      @posts = Post.all
    end
  end
  </code></pre>
  
  <p>and my test:</p>
  
  <pre><code>require "spec_helper"
  
  describe PostsController do
    let(:post){FactoryGirl.create(:post)}
      context "JSON" do
        describe "GET #index" do
          it "should access index" do
             get :index
          end
        end
     end
  end
  </code></pre>
  
  <p>and my routes.rb</p>
  
  <pre><code> AuthApp::Application.routes.draw do
     resources :posts
   end
  </code></pre>
  
  <p>but after run</p>
  
  <pre><code>$ rspec spec
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>1) PostsController JSON GET #index should access index
       Failure/Error: get :index
       ActionView::MissingTemplate:
         Missing template posts/index, application/index with {:locale=&gt;[:en], :formats=&gt;[:html], :handlers=&gt;[:erb, :builder, :jbuilder]}. Searched in:
           * "#&lt;RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator:0x007fbfb62d64a0&gt;"
       # ./spec/controllers/post_controller_spec.rb:9:in `block (4 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>How can access to /posts with index action instead of /posts/index?</p>
  
  <p>Thanks in advance,</p>