Thank you, I haven’t tried delayed attribute evaluation before, will research about it. But any idea on what is causing this issue? Is it because attrs[:body] is nil so it evaluates the other side of the OR?
Also in this case,
def comment_factory(attrs \\ %{}) do
%Comment{
body: Faker.Lorem.sentence(),
post: build(:post)
}
end
does exmachina by behavior override the body if I do
I can’t remember now – sorry. I could only theorize that nil isn’t deemed a valid attribute value? But that wouldn’t make sense.
I stopped using ex_machina in favour of domain/business-specific modules that create objects, which increased certainty factor in tests as well. You can add a very thin layer on top of that that imitates ex_machina if you really need the random data.