Using seed and changeset generators with child resources
I have a
- generate the
-
-
- optionally accept a parent id to bypass parent generation
-
-
- have this work in property tests
My first try with the changeset generator looks like this. It works, but I don't like it.
I poked away at an implementation using
I have a few questions:
- What is the best way to do this?
- Does anyone else use the generators in this way?
- Is the purpose of
- Why the difference in interface between
Thanks
Child resource that belongs_to a Parent. I'd like to use the seed and changeset generators with these resources in my tests. I'd like to- generate the
Child along with a unique Parent in one generator call-
child = generate(child_seed()) -
child = generate(child_changeset())- optionally accept a parent id to bypass parent generation
-
child = generate(child_seed(parent_id: 123)) -
child = generate(child_changeset(parent_id: 123))- have this work in property tests
My first try with the changeset generator looks like this. It works, but I don't like it.
I poked away at an implementation using
seed_generator but failed to get something that worked.I have a few questions:
- What is the best way to do this?
- Does anyone else use the generators in this way?
- Is the purpose of
uses to wrap constants with StreamData.constant?- Why the difference in interface between
seed_generator and changeset_generator beyond changeset_generator taking an action?Thanks
