This has been causing some frustration recently...
It seems that using Factories in my cucumber tests, in some situations causes AssociationTypeMismatch
errors such as:
MyModel(#65776650) expected, got MyModel(#28190030) (ActiveRecord::AssociationTypeMismatch)
These seem to happen when there is an association reference - as if the Factory created object is different to the real one. See this question for more details: Cucumber duplicate class problem: AssociationTypeMismatch
I have been gradually changing Factory calls to real Model.create or mock_model calls. It would be nice to keep using Factory girl... I wonder if there is something I may have done wrong?
Thank you
reload!
in a console window and then go on to create Factories. Solution is just to restart your console session. – Certifiablereload!
mentioned by @Chrisbloom7 works. Just a bit of a pain to keep restarting rails console – Misadviseclass_name
attribute was incorrectly set in the model. – Camera