title: rspec rails mocking session hash
body: <p>I am trying to mock out the session hash for a controller like so:</p>
  
  <pre><code>it "finds using the session[:company_id]" do
    session.should_receive(:[]).with(:company_id).and_return 100
    Company.should_receive(:find).with(100)
    get 'show'
  end
  </code></pre>
  
  <p>When I call get 'show' it states:</p>
  
  <pre><code>received :[] with unexpected arguments  
  expected: (:company_id)  
     got: ("flash")
  </code></pre>
  
  <p>The controller code looks like:</p>
  
  <pre><code>def show
    company_id = session[:company_id]
    @company = Company.find params[company_id]
  end
  </code></pre>
  
  <p>I have also simply tried setting</p>
  
  <pre><code>it "finds using the session[:company_id]" do
    session[:company_id]= 100
    Company.should_receive(:find).with(100)
    get 'show'
  end
  </code></pre>
  
  <p>but then get an issue about:</p>
  
  <pre><code>expected: (100)
  got: (nil)
  </code></pre>
  
  <p>Anyone have ideas why?</p>