I work with changeset/seed generators a fair bit in tests and I always find myself struggling to get things working when one generated attribute relies on another.
As an example, let's say I want to generate a "document" that has a draft/published status, and I have a validation that disallows creating a document in a published state unless it is "in" a folder (i.e. a folder is a belongs_to relationship that is required when the document is published). The generator can generate published or draft documents. If the document is a draft, there should be no folder relationship, but if it's published, it must have one. I need to be able to generate a folder for it to exist in if and only if the document being generated is published.
This is obviously a bit contrived, but something along these lines has come up for me multiple times.
Is there any "blessed" way to basically generate these attributes together/dependent on each other?