Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument Error: Not registered using factory_girl 1.1.0 with rails 3.1.0.rc8 #194

Closed
matthewbga opened this issue Aug 29, 2011 · 4 comments

Comments

@matthewbga
Copy link

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 #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?

@joshuaclayton
Copy link
Contributor

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.

@matthewbga
Copy link
Author

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.

@joshuaclayton
Copy link
Contributor

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

@brendon
Copy link

brendon commented Nov 21, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants