I am using STI in my current project and would like to be able to test the base class in isolation. Unfortunately, when I try to create an instance of the base class the fake value being inserted into the type
column causes an error.
Invalid single-table inheritance type: fakevalue is not a subclass of MyTable
Since I could potentially have an unlimited number of subclasses, I would like to be able to test my base class in complete isolation from the subclasses. Since Rails is checking for the subclass this appears to be impossible.
Is there a way?
So after discussing with a coworker, we came to the following solution.
In the spec file, I added an empty dummy class and inherited from my base class. I can then test using this dummy class. Since the dummy class is empty the only logic that gets tested is the base class. I can then add/remove subclasses without fear of breaking the base class tests.