Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8356329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:09:44+00:00 2026-06-09T10:09:44+00:00

Ive been following this introductory to Rails testing and Ive run into an issue

  • 0

Ive been following this 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.

Anyhow, I have a very basic model test, not even fully implemented and when I try and run rspec spec/models/admin_spec.rb. I get the following error in the Admin has a valid factory line (full code below)

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 <top (required)>'

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

Thanks very much for your help

Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.2'
gem 'mysql2'
gem 'jquery-rails'
gem 'haml'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'bootstrap-sass', '~> 2.0.2'
gem 'capistrano'
gem 'json'
gem "paperclip", '~>3.0'
gem 'airbrake'
gem 'acts_as_list'
gem 'nested_form', :git => 'https://github.com/ryanb/nested_form.git'
gem 'bootstrap-wysihtml5-rails'
gem 'will_paginate', '~> 3.0'
gem 'bootstrap-will_paginate'
gem 'thinking-sphinx', '2.0.10'

gem 'sass-rails', '~> 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 => false
  gem 'faker'
  gem 'capybara'
  gem 'guard-rspec'
  gem 'launchy'
end

/spec/factories/admin.rb

require 'faker'

FactoryGirl.define do
  factory :admin do |f|
    f.name Faker::Name.name
    f.email Faker::Internet.email
  end
end

/spec/models/admin_spec.rb

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:09:48+00:00Added an answer on June 9, 2026 at 10:09 am

    It should be FactoryGirl.create instead. Apparently Factory was deprecated and now has been removed, look at the comments in the link you provided 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been looking for this answer for hours, but I cant find it. I
I've been following this post http://martinciu.com/2011/01/mounting-grape-api-inside-rails-application.html I put the module into the lib directory
Im pretty new to Linux in general. Ive just been following this tutorial(http://net.tutsplus.com/tutorials/php/how-to-setup-a-dedicated-web-server-for-free/) to
Ive been googling for the last few hours to find a solution to my
Ive been trying to convert my asp.net website into a web application following the
Ive searched everywhere for this but cant find the answer. I have used the
I've been following this article to display ActiveRecord data in QtRuby. I've copied the
I've been following this tutorial: http://emumair.wordpress.com/2011/03/17/social-network-authentication-with-omniauth-and-authlogic/ . I've walked through it all and I'm
So I've been following this tutorial on JPagination and on the section about with
I'm trying to deal with @javax.faces.bean.ManagedProperty but without success ! I've been following this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.