Description of problem: - I\'ve setup factory_girl_rails however whenever I try and load a factory it\'s trying to load it multiple times.
Envir
I resolved it by removing spec/factories/xxx.rb from command line:
rspec spec/factories/xxx.rb spec/model/xxx.rb # before
rspec spec/model/xxx.rb # after
I have the same the problem. What I do is move the spec/factories.rb to spec/factories/role.rb
I defined the same name factory at factories.rb, and I just found that someone else define the same factory below the directory of factories. So actually I can just use it without define another one.
I had the same problem recently. In my case one of the files in /factories had a _spec.rb ending (result of creative cp use). It was loading twice, first by rspec and then as a factory.
I renamed spec/factories as spec/setup_data and the problem gone. Try renaming the spec/factories to anything that suites you, should work.
Is there any chance you pasted this whole snippet for the support file from the config docs?
# RSpec
# spec/support/factory_girl.rb
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
# RSpec without Rails
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
FactoryGirl.find_definitions
end
end
If you read the comments you'll see you only want one block or the other. I made this mistake and got the error stated in the question.