title: How to use mock_model in spec_helper (for use with Authlogic)
body: <p>I'm upgrading to rails 3 and rspec 2.</p>
  
  <p>I'm getting the error "undefined method `mock_model'" in my spec_helper. My current_user method sets up a mock user for authlogic and generates this error.</p>
  
  <p>My spec helper looks like this</p>
  
  <pre><code>require 'authlogic/test_case'
  require 'shoulda'
  require 'helpers'
  
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f}
  
  RSpec.configure do |config|
    config.mock_with :rspec
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
    config.use_transactional_fixtures = true
  end
  
  module LoginHelper
     include Authlogic::TestCase
  
     def login_user person
       activate_authlogic
       UserSession.create(...)
     end
  end
  include LoginHelper
  
  
  def current_user(stubs = {})
    @current_user ||= mock_model("User", stubs)
  end
  
  def user_session(stubs = {}, user_stubs = {})
    @current_user ||= mock_model(UserSession, {:user =&gt; current_user(user_stubs)}.merge(stubs))
  end
  
  def login(session_stubs = {}, user_stubs = {})
    UserSession.stub!(:find).and_return(user_session(session_stubs, user_stubs))
  end
  
  def logout
    @user_session = nil
  end
  </code></pre>