title: Rails 3.2, RSpec, Factory Girl : NameError: uninitialized constant Factory
body: <p>Ive been following <a href="http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html">this</a> introductory to Rails testing and Ive run into an issue I cant seem to find the solution to. Im very familiar with Rails but this is my first foray into testing.</p>
  
  <p>Anyhow, I have a very basic model test, not even fully implemented and when I try and run <code>rspec spec/models/admin_spec.rb</code>. I get the following error in the <code>Admin has a valid factory</code> line (full code below)</p>
  
  <pre><code>Admin has a valid factory
   Failure/Error: Factory.create(:admin).should be_valid
   NameError:
     uninitialized constant Factory
   # ./spec/models/admin_spec.rb:6:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>I assume FactoryGirl isnt being loaded for some reason but I was under the impression it should be automatically loaded. Below is the full code from my Gemfile, /spec/models/admin_spec.rb and /spec/factories/admins.rb</p>
  
  <p>Thanks very much for your help</p>
  
  <p><strong>Gemfile</strong></p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '3.2.2'
  gem 'mysql2'
  gem 'jquery-rails'
  gem 'haml'
  gem 'bcrypt-ruby', :require =&gt; 'bcrypt'
  gem 'bootstrap-sass', '~&gt; 2.0.2'
  gem 'capistrano'
  gem 'json'
  gem "paperclip", '~&gt;3.0'
  gem 'airbrake'
  gem 'acts_as_list'
  gem 'nested_form', :git =&gt; 'https://github.com/ryanb/nested_form.git'
  gem 'bootstrap-wysihtml5-rails'
  gem 'will_paginate', '~&gt; 3.0'
  gem 'bootstrap-will_paginate'
  gem 'thinking-sphinx', '2.0.10'
  
  gem 'sass-rails', '~&gt; 3.1'
  gem 'coffee-rails'
  gem 'uglifier'
  # gem 'compass'
  
  group :development do
    gem 'awesome_print'
    gem 'wirble'
  end
  
  group :development, :test do
    gem 'rspec-rails'
    gem 'factory_girl_rails'
  end
  
  group :production do
    gem 'execjs'
    gem 'therubyracer'
  end
  
  group :test do
    # Pretty printed test output
    gem 'turn', :require =&gt; false
    gem 'faker'
    gem 'capybara'
    gem 'guard-rspec'
    gem 'launchy'
  end
  </code></pre>
  
  <p><strong>/spec/factories/admin.rb</strong></p>
  
  <pre><code>require 'faker'
  
  FactoryGirl.define do
    factory :admin do |f|
      f.name Faker::Name.name
      f.email Faker::Internet.email
    end
  end
  </code></pre>
  
  <p><strong>/spec/models/admin_spec.rb</strong></p>
  
  <pre><code>require 'spec_helper'
  
  describe Admin do
    it "has a valid factory" do
      Factory.create(:admin).should be_valid
    end
    it "is invalid without a name"
    it "is invalid without an email"
  end
  </code></pre>