RSpec Logged In Helper

This is what I’m using to help out with actions and views that require a logged in user

spec_helper.rb
  
module LoggedInHelper
  def mock_globals
    @current_user = mock_model(User, :id => 1)
  end
end

describe "Logged In Action", :shared => true do
  include LoggedInHelper
  
  before(:each) do
    mock_globals
    
    controller.stub!(:current_user).and_return(@current_user)
  end
end

describe "Logged In View", :shared => true do 
  include LoggedInHelper
  
  before(:each) do
    mock_globals
    
    template.stub!(:current_user).and_return(@current_user)
    template.stub!(:logged_in?).and_return(true)
  end
end
  
profiles_controller_spec.rb
  
require File.dirname(__FILE__) + '/../spec_helper'

describe QuestionMonitorsController do
  it_should_behave_like "Logged In Action"

  #your specs here
end
  
show.html.erb_spec.rb
  
require File.dirname(__FILE__) + '/../../spec_helper'

describe "/profiles/show" do
  it_should_behave_like "Logged In View"

  #your specs here
end