title: How can I use rspec shared_examples to test my controllers?
body: <p>I'm upgrading a site to use devise and I have the following specs to test <code>SitesController</code>:</p>
  
  <pre><code>describe SitesController do
    let(:user)  { FactoryGirl.create(:user)  }
    let(:admin) { FactoryGirl.create(:user, :admin) }
  
    shared_examples "disallow get index" do
      get :index
      response.should_not be_success
    end
  
    context "with user signed in" do
      before(:each) { sign_in user }
  
      it "disallowes / with GET" do
        get :index
        response.should_not be_success
      end
  
      it_behaves_like "disallow get index"
    end
  
    context "with admin signed in" do
      before(:each) { sign_in admin }
  
      it "allowes / with GET" do
        get :index
        response.should be_success
      end
    end
  end
  </code></pre>
  
  <p>I want to add a context where no user is signed in and use the shared example <code>disallow get index</code> to specify that you can't do that if you're not signed in. BUT, when I add <code>it_behaves_like "disallow get index"</code> I get this undefined method error:</p>
  
  <pre><code>sites_controller_spec.rb:8:in `block (2 levels) in &lt;top (required)&gt;': undefined method `get' for #&lt;Class:0x00000101746718&gt; (NoMethodError)
  </code></pre>
  
  <p>So, why does this work when I explicitly call <code>get :index</code> but not in a shared example group?</p>