-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Invoke factory with class name instead of factory name #740
Comments
What if you tried this? FactoryGirl.define do
factory(:"ModelNamespace::OtherModel") do
# factory stuff
end
end
FactoryGirl.create(ModelNamespace::OtherModel) |
I hit this bug as well. For a quick workaround you can register the same (named) factory again with the class name and avoid duplication of all attributes: FactoryGirl.define do
factory :panel do
# factory stuff
# register the same factory for the class as well
factory(Panel)
end
end |
monkbroc
added a commit
to monkbroc/factory_girl
that referenced
this issue
Dec 7, 2015
Namespaced models like `Invoice::Item` should be able to be found by `FactoryGirl.create(Invoice::Item)` if registered as `factory :invoice_item`. I added a test for this new behavior. Fixes thoughtbot#740
This was an unintended effect and has been deprecated: #843 In FG5, only accessing via symbol will work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've got an ActiveRecord model and a basic factory set up for it, under the normal Rails naming convention:
I've noticed in my RSpec tests I can invoke this factory with either the factory name or the model's class name:
The latter is preferable, because it means I can replace literal symbols with RSpec's
described_class
helper.So now, I've got another model that I'm attempting to do this for, but when invoking the factory, I see:
I've defined the model and factory as follows:
Is there a way I could redefine either to fix the resolution issue, or am I misusing this feature of FactoryGirl?
The text was updated successfully, but these errors were encountered: