Skip to content


Subversion checkout URL

You can clone with
Download ZIP


error Not registered: factory in fixtures file #15

dieuit07 opened this Issue · 4 comments

2 participants


Hi everyone,
When I run spec, I give this:
There was an error building fixtures
#<ArgumentError: Not registered: user>

In my spec_helper:
require 'rubygems'
require 'spork'
require 'factory_girl'
require 'simplecov'
SimpleCov.start 'rails'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'fixtures'

Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f}
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}


In fixtures_builder/user.rb
test = Factory(:user)

If I place content user_factory.rb in the top file fixtures_builder/user.rb, It run ok

Did I config something wrong?


That error is actually coming from Factory Girl. But it is probably due to using spork.

Make sure you do the following in your Spork each run:

Spork.each_run do

Basically that message is when factory girl runs, and it doesn't have you factories loaded by the time it runs the test. Adding the FactoryGirl reload should make sure it is there in time without having to adjust your requires.

@rdy rdy closed this

I do it follow your advise
```Spork.each_run do

but it still have this error

you might also want to try the gem 'factory_girl_rails' instead of just gem 'factory_girl' which properly loads the factories at the right time which could also be the problem.


not thing change :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.