Hi! On Sun, Jun 24, 2007 at 01:35:46PM -0500, David James wrote: > I need to reset the ferret index between test runs. > > It seems like there are a few ways to reset the ferret index. > * Deleting the index directory -- is this really bad form?
Not really, but it can cause problems if you have an index instance open in this directory. Closing any open indexes and them removing the directory is the best way to ensure the index is cleared out. > * calling rebuild_index You should do this after removing the old index, of course ;-) In theory, removing the old index before calling rebuild_index should not be needed, but it won't hurt either: Model.aaf_index.close FileUtils.rm_rf Model.aaf_configuration[:index_dir] Model.rebuild_index > What would y'all recommend? (Sorry, I'm from Texas) In general you should think about how often you need the index to be rebuilt. With larger fixture volumes reindexing in your setup method can really slow down your tests - in this case think about only rebuilding the index less frequently, i.e. only before the tests that really need the index are run. You could also split your tests in index changing and not index changing tests, and choose the appropriate rebuild frequency on a case by case basis to reduce the slow down by frequent rebuilds. If you keep an index to be used for testing ready somewhere, replacing RAILS_ROOT/index/test/model with this one in setup should work, too. Just be sure to call Model.aaf_index.close before replacing the index directory to avoid any hickups. Replacing the persistent index directory implementation used in tests with a RAMDirectory based on a persistent test index that is never changed is a good idea, too, but won't work with acts_as_ferret out of the box. Jens -- Jens Krämer webit! Gesellschaft für neue Medien mbH Schnorrstraße 76 | 01069 Dresden Telefon +49 351 46766-0 | Telefax +49 351 46766-66 [EMAIL PROTECTED] | www.webit.de Amtsgericht Dresden | HRB 15422 GF Sven Haubold, Hagen Malessa _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

