I was trying to use StreamData with test factory functions based off of what is in “What’s new in Ecto 2.1” book (or also close to what the ExMachina package does). I created a generator for a struct and used it inside the factory function for that struct, but noticed whenever it was called, the generator was returning the same value. I’m assuming because I’m running the generator the first time each time? Has any tried the above with any success?
I’ve created a GitHub gist with some examples how to use StreamData as Ecto factories. I’m not sure if it is the perfect implementation, but it works. I’ll gladly improve it if you or others have suggestions.
@ibarch thanks! This looks awesome. One question: are the values different each time you get a structural back from the factory? I think that was an issue I had as well. But definitely going to give this a spin
Yes, they are. Unless you override them with your own attributes.