Is there a way to hook into ExMachina in order to perform an action post insert?
I have a scenario where in my unit test after performing two separate inserts, I repeatedly need to take an action on the two items as exemplified by this contrived example
test "my test" do
a = insert(:a)
b = insert(:b, attribute: a)
Logbooks.write_entry_for(a, b)
assert ...
end
I would like to automate calling Logbooks.write_entry_for()
whenever insert(:b, attribute: a)
happens but calling it inside the definition of b_factory
doesn’t work as b
itself isn’t persisted at that point.
Does anyone know of a way to solve this?