Some of my tests don’t work because of saved data in my database. I found out (code below) that the create function of FactoryGirl doesn’t go through the controller steps to ensure that everything defined in the controller is passed. One thing that my controller does is format an attribute before saving to database to ensure that a string is saved and not an array, e.g. “Monday,Tuesday” instead of [“Monday,Tuesday”].
if Schedule.count == 0
FactoryGirl.create(:schedule)
end
How do I set the before statement to make the create functionality execute controller steps?
Solved this by putting the following line:
Full test is: