This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Hi everyone, we’ve just tried splitting our fixtures throughout the components/packs in our app, only to discover Rails does not currently support this
Before we open a PR to support this in Rails, has anyone else tackled this issue already in some other creative way?
I haven’t encountered this — we use factory bot which is configured to work across packs with stimpack (adding multi-pack rails fixture support to stimpack once rails supports it might be a nice addtion).
One thing to note though is that we have various systems that don’t yet have multi-pack support (another example is sorbet RBI generators which put things in the root), but surprisingly we found it’s actually not terribly bothersome to have that inconsistency at least in the short-term.
That makes sense, thank you Alex.
To clarify, we also use factory_bot
in most of our tests, but we still rely on some old-school fixtures warm-up to avoid our specs spending too much time on seeding the DB with extremely common data
I don’t know much about old-school fixtures, but could you do something like this:
# path/to/fixture/file/in/root.rb
MyOtherSystem.load_fixtures
MyOtherOtherSystem.load_fixtures
# path/to/other/systems.rb
module MyOtherSystem
def self.load_fixtures; ...; end
end
This way we still satisfy rails by having the top-level fixture file, but the substantial part of the work is split across packages? Not sure if it works since I’m not familiar with the existing architecture, just spitballing.
I’m not a big fan of fixtures either to be fair, I haven’t used them for years
This was a request coming from the team. I’ll definitely pass on your suggestion though: if fixtures are controlled by a ruby script, I don’t see why this wouldn’t work!