Perry Smith wrote:
But I have another problem. I have a deferred constraint which means
that it does not trigger until the commit. But... the test rig does not
do a commit. It just rolls back the changes. Sort of a cute trick I
suppose but in my case, it is effectively disabling my constraint.
I thought I saw somewhere where you could not run your tests this way.
That it would use another approach. But I don't know if I'm dreaming or
not. I have not found how to do it yet.
The global technique is in test/test_helper.rb:
self.use_transactional_fixtures = true
The cheap solution appears to involve setting that to 'false', and running all tests in committed mode.
Note that transactions are not to keep your test data isolated. Fixtures take care of that. The transactions help the tests go fast, because they reduce database activity to a series of in-memory or buffered manipulations. At rollback time these vanish efficiently, without causing your hard drive's read-write heads to move or anything.
So you might notice slower tests. I would research some way to change that item per-test, but you must do that before the test's fixture system engages, so that would involve reading the source, monkey-patching, and other fun things.
Anything for faster tests!!!