title: rspec mocking "undefined method `stub_model' for #<Class:0x007ff9c339bd80> (NoMethodError)"
body: <p>I'm using Rails 3.1 and I wanted to add some stubs and mocks to my specs but I get a NoMethodError:</p>
  
  <pre><code>undefined method `stub_model' for #&lt;Class:0x007ff9c339bd80&gt; (NoMethodError)
  </code></pre>
  
  <p>Here is an excerpt of my GemFile:</p>
  
  <pre><code>gem 'rspec'
  gem 'rspec-rails'
  </code></pre>
  
  <p>I ran bundle install and rails g rspec:install</p>
  
  <p>And here is the code that tries to create a stub_model</p>
  
  <pre><code>  0     @flight = stub_model(Flight)
    1     Flight.stub! (:all).and_return([@flight])
  </code></pre>
  
  <p>And here is spec_helper.rb:</p>
  
  <pre><code>  0 # This file is copied to spec/ when you run 'rails generate rspec:install'
    1 ENV["RAILS_ENV"] ||= 'test'
    2 require File.expand_path("../../config/environment", __FILE__)
    3 require 'rspec/rails'
    4 
    5 # Requires supporting ruby files with custom matchers and macros, etc,
    6 # in spec/support/ and its subdirectories.
    7 Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
    8   
    9 RSpec.configure do |config|
   10   # == Mock Framework
   11   #
   12   # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
   13   #
   14   # config.mock_with :mocha
   15   # config.mock_with :flexmock
   16   # config.mock_with :rr
   17   config.mock_with :rspec
   18 
   19   # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
   20   config.fixture_path = "#{::Rails.root}/spec/fixtures"
   21     
   22   # If you're not using ActiveRecord, or you'd prefer not to run each of your
   23   # examples within a transaction, remove the following line or assign false
   24   # instead of true.
   25   config.use_transactional_fixtures = true
   26 end 
  </code></pre>
  
  <p>I'm calling "rspec ./spec" and "bundle exec rspec ./spec"  (tried both, no difference)</p>
  
  <p>Everything I'm doing seems to be textbook (in fact, I'm following The Rails 3 Way).</p>
  
  <p>What am I missing?</p>