I'm writing unit tests for a rails app whose behavior depends on the relationships of tens of thousands of items in a DB. I need this data in the test DB for a lot of tests. Storing this data as fixtures, keeping it in sync with the production DB, and waiting HOURS for the fixtures to load whenever the test suite is run are all untenable options.
Here is what I <i>think</i> what I want to do: * Create a reference archive of the test DB once all the data is loaded. This will be checked into the repo so anyone can load it (quickly and easily with a capistrano task) prior to running the test suite.
* Trick rails into believing the data was loaded from fixtures, so tests will behave normally. Presumably this means overriding the standard procedure of deleting, re-inserting, and instantiating test data that happens before each test method. I believe this could probably be done with a test_helper method without having to modify ActiveRecord.
Concerns: * This seems to be in violation of the Rails philosophy of "make right things easy and the wrong things hard."
* I think this has to be a fairly common problem, but after lots of google searching, I have found no instances of someone else trying to do this sort of thing.
This makes me think there is a better way, or at least a different way that someone has already implemented.
What I am looking for: * A reality check. Is this the right way to handle this problem?
* Technical guidance. I am a relative novice (read: n00b) with ruby development, so any input on things I should be aware of as I try to figure this out would be helpful...
- OR -
* Sample code. If someone has already solved this problem and talked about it somewhere, just point me in their direction.
Thanks, John