Skip to content

Added check to maintain definitions after subsequent imports.#22

Open
jordanyaker wants to merge 1 commit intoCoffa:masterfrom
jordanyaker:master
Open

Added check to maintain definitions after subsequent imports.#22
jordanyaker wants to merge 1 commit intoCoffa:masterfrom
jordanyaker:master

Conversation

@jordanyaker
Copy link
Contributor

We are using FactoryGirl on a project involving polymer.js and are defining factories in different components. For any component where we import two or more factories, the last import was the only set of definitions that "took".

Given that two components (i.e., xh-data-events and xh-api-device) both import factory_girl.js, if you have the following snippet of code:

    <link rel="import" href="../../xh-data-events/tests/factories/index.html">
    <link rel="import" href="../../xh-api-device/tests/factories/index.html">

The second import will cause another import of factory_girl.js. This would in-turn cause the re-initialization of the FactoryGirl global module and the loss of any definitions that were made as part of xh-data-events.

Adding a simple check to the compilation template files remedies this problem. Additionally, the use of the lazy logic initializers (i.e., foo && bar || rab) will ensure that FactoryGirl is initialized at this level no matter what.

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

Successfully merging this pull request may close these issues.

1 participant