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

Trait not registered: class #276

Closed
ghost opened this issue Jan 19, 2012 · 3 comments
Closed

Trait not registered: class #276

ghost opened this issue Jan 19, 2012 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 19, 2012

I'm working on a rails 3.1.3 app. I wanted to check out rails 3.2.0.rc2. After updating the rails gem, I started getting this error from factory girl.

I've put together a couple gists that include my gemfile and factories, and the output I'm seeing.

before and after

The only changes that have been made from before to after are to the gemfile.

@joshuaclayton
Copy link
Contributor

Is this the full and unmodified version of the factory file? The things that stand out to me are that it's looking for a trait when you're clearly asking for an association (at least, that's what it seems like to me). The implicit declaration is where this is determined: https://github.com/thoughtbot/factory_girl/blob/master/lib/factory_girl/declaration/implicit.rb Why it's not recognizing that as another factory is boggling me.

If you have the real factories available, that would probably help a lot. Thanks!

@ghost
Copy link
Author

ghost commented Jan 20, 2012

@joshuaclayton Thanks for replying so quickly. The code is from a client project, which is why I posted the edited factories. I thought I'd posted the important bits, but apparently not.

I've updated the before gist to reflect the entire factories.rb file (with the model names changed). This led me to the fix:

Apparently calls to fixture_file_upload need to be wrapped in {}. Where I had

attachment fixture_file_upload(Rails.root.join(*%w[ spec data child_a.txt ]), 'text/plain')

should be

attachment { fixture_file_upload(Rails.root.join(*%w[ spec data child_a.txt ]), 'text/plain') }

instead.

@ghost ghost closed this as completed Jan 20, 2012
@joshuaclayton
Copy link
Contributor

Ah, yeah, that'll do it. Typically I wrap all my attributes where I assign values in blocks. It shouldn't cause a slowdown and it helps prevent some of these oddities :-)

This issue was closed.
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

1 participant