factory_bot
factory_bot copied to clipboard
Rough draft of Namespaced Factories
See: https://github.com/thoughtbot/factory_bot/issues/199
I have a number of clients who use FactoryBot and are working through the difficult challene of decomposing a large monolith into either domain-driven namespaces; or small gems/engines that are "plugged into" a larger monolith.
In most cases, we've been able to get away with keeping the factories bundled with their extracted modules and using distinct names.
However there's also been a bit of copy-pasting of factory code back into the monolith in cases where the names really do need to be shared.
This is an attempt to bring @joshuaclayton's example of namespacing into the core FactoryBot DSL.
If you'd prefer I packaged this as it's own gem, I'd be happy to do so; but I'd be stoked to see this in the core FactoryBot package!
@entcheva I'm an unrelated third party, but is there any progress on this? I looks like this PR is waiting on ThoughtBot's response.
@elliotcm - I've been using this in production for about a year and a half now. It's not perfect; but I'd be down to publish it as a standalone gem sometime this week if you'd like.
@elliotcm - I've been using this in production for about a year and a half now. It's not perfect; but I'd be down to publish it as a standalone gem sometime this week if you'd like.
@zspencer That'd be great! Thanks.
@elliotcm - https://github.com/zinc-collective/factory_bot_namespaced_factories Here ya go! I just pulled it out of the production application I've been using it in since 2020. We mostly relied on our relatively comprehensive test suite to actually test the gem; but if you want to add better docs / specs / etc. I'd be happy to take patches!
@zspencer AGPL? Wouldn't that license prevent me from using this in a closed-source business application?
@gap777 - My understanding is that AGPL is safe to use in proprietary applications; so long as you're not distributing it as part of your production deployment. That said, I believe Sidekiq uses the LGPL so maybe I am mixed up.