Great article! Didn't know you could do this on FactoryBot. Is this similar to the FactoryBot's use_parent_strategy?
use_parent_strategy is something different (more info on their docs), it tells FactoryBot whether or not to use the parent's strategy (eg: build or create).
For example, given a model User and Country (User belongs_to Country), when use_parent_strategy=true, calling build(:user) will also build (instead of create) the associated Country, because it follows the "parent strategy of build".
However, FactoryBot custom strategies is something different that I want to explore. Perhaps defining a new find_or_create strategy.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.