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

Fails to pluralize factory in unit test #162

Closed
YoranBrondsema opened this issue Apr 14, 2015 · 4 comments
Closed

Fails to pluralize factory in unit test #162

YoranBrondsema opened this issue Apr 14, 2015 · 4 comments

Comments

@YoranBrondsema
Copy link

I have a set of custom objects which I register in the namespace factory. All these objects are located in the folder /app/factories. I register them in an initializer:

application.register('factory:objectA', ObjectAFactory);
application.register('factory:objectB', ObjectBFactory);
...

When I unit test such a Factory object with:

moduleFor('factory:objectA')
...

It returns an error TypeError: Attempting to register an unknown factory: 'factory:objectA'. However, if I change it into

moduleFor('factorie:objectA')
...

then the tests succeed.

So I think there's something wrong with how the pluralization works in the resolver.

@rwjblue
Copy link
Member

rwjblue commented Apr 14, 2015

You need to customize your resolver to tell it about your pluralization rules. See ember-cli/ember-resolver#68 for details.

@rwjblue
Copy link
Member

rwjblue commented Apr 14, 2015

The inflector that is present in ember-data would have properly handled this case (which is I'm sure why this was confusing), but we need to keep the resolver as light as possible (dependency wise) so we can't embed the inflector here. And since types in the system are generally static up front, it is "easy" enough to just define the translations for the resolver to use (and then it can fall back to "just add 's'").

@rwjblue
Copy link
Member

rwjblue commented Apr 14, 2015

Also, when you teach the resolver your pluralization rules you can delete that initializer (the resolver will lazily look up the factories as it needs to).

@YoranBrondsema
Copy link
Author

Ok, that makes sense. Thanks for the quick reply and the explanation!

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

2 participants