I am working on a Mountable Engine in rails 3.1.0.rc8 and am getting "Argument Error: Not registered: user1" when I run factory_girl.
Reading https://github.com/thoughtbot/factory_girl/issues/168, I see where you suggested the dev to run FactoryGirl.definition_file_paths from rails console. Suspecting the same issue, I tried this, and received:
=> ["/Users/mab/Documents/Development/mountable_engine_tests/gemmy/spec/dummy/test/factories", "/Users/mab/Documents/Development/mountable_engine_tests/gemmy/spec/dummy/spec/factories"]
Since this is a mountable engine, I had been putting the specs, fixtures, and everything in Users/mab/Documents/Development/mountable_engine_tests/gemmy/spec, WITHOUT the /dummy. So my factories are in Users/mab/Documents/Development/mountable_engine_tests/gemmy/spec/factories.
According to the docs I've been reading on mountable engines everywhere, the factories should not be under dummy. Can you advise?
TIA,
-Matt
Any advice on how to repair this?
Are the factories part of the engine or part of your tests for the engine? I'm not too sure I understand what you're trying to achieve here.
Haha, thanks for the reply, joshuaclayton. I may well be the issue here!
I have a models-only engine I want to use among three separate projects, so I only need model testing in the Engine, but I do want to have it there. My thinking was to use the Mountable Engine for this purpose. At this point I've pulled back from making it mountable as in this case I don't need the namespacing, and the magic-luggage with --mountable appears to have been causing me trouble.
I was able to get around the issue with factory_girl, however, by putting the following in my spec_helper.rb.
FactoryGirl.definition_file_paths << File.join(File.dirname(FILE), 'factories')
FactoryGirl.find_definitions
It appears the default behavior was to point to factories down in /dummy, however, spec and the others seem to prefer having tests, etc. up in /spec.
In the end it makes no difference to me, but I thought you guys would want to know there appears to be a divergence here with rspec using one structure and factory_girl using the other.
Thanks again.
What you ended up writing (adding the path to Factory Girl's definition_file_paths) is exactly what I would've recommended you do to get the paths wired up correctly
In addition to this I found that I had to require 'factory_girl' at the top of spec_helper.rb. There's also an error in the code above because it was markdowned:
FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
FactoryGirl.find_definitions
Most helpful comment
In addition to this I found that I had to
require 'factory_girl'at the top ofspec_helper.rb. There's also an error in the code above because it was markdowned: