Is there a way to reliably test the acts_as_ferret plugin using RoR functional tests? I load my fixtures and no matter what I do, the test won''t return a result for what *should* be a query that returns results. Any help on this would be greatly appreciated. FIXTURE ******** article_001: id: 1 title: some valid article title body: This is a valid article entry with some images and stuff. FUNCTIONAL TEST ****************** def test_search get :search, :q => "some valid article title" assert_equal 1, assigns(:articles).size end MODEL ******* acts_as_ferret( { :fields => { ''title'' => { :boost => 2 }, ''body'' => { :boost => 1.5 }, ''ferret_index_article_comments'' => { :boost => 1 }, ''ferret_index_article_image_captions'' => { :boost => 1.5 } } }, { :analyzer => Ferret::Analysis::StandardAnalyzer.new([nil]) } ) -- Posted via http://www.ruby-forum.com/.
On Fri, Dec 01, 2006 at 08:56:20PM +0100, Mark wrote:> Is there a way to reliably test the acts_as_ferret plugin using RoR > functional tests? I load my fixtures and no matter what I do, the test > won''t return a result for what *should* be a query that returns results. > Any help on this would be greatly appreciated.the problem is, that fixtures aren''t loaded through active record, so no ferret indexing can takes place. You have to call Article.rebuild_index before running your tests (e.g. in setup), or create your test data through active record inside your test case. Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Jens Kraemer wrote:> On Fri, Dec 01, 2006 at 08:56:20PM +0100, Mark wrote: >> Is there a way to reliably test the acts_as_ferret plugin using RoR >> functional tests? I load my fixtures and no matter what I do, the test >> won''t return a result for what *should* be a query that returns results. >> Any help on this would be greatly appreciated. > > the problem is, that fixtures aren''t loaded through active record, so no > ferret indexing can takes place. You have to call > Article.rebuild_index before running your tests (e.g. in setup), or > create your test data through active record inside your test case.Right on Jens! That worked like a charm. I hadn''t originally considered the fact that the fixtures aren''t loaded through ActiveRecord. -- Posted via http://www.ruby-forum.com/.
Jens Kraemer wrote:> On Fri, Dec 01, 2006 at 08:56:20PM +0100, Mark wrote: >> Is there a way to reliably test the acts_as_ferret plugin using RoR >> functional tests? I load my fixtures and no matter what I do, the test >> won''t return a result for what *should* be a query that returns results. >> Any help on this would be greatly appreciated. > > the problem is, that fixtures aren''t loaded through active record, so no > ferret indexing can takes place. You have to call > Article.rebuild_index before running your tests (e.g. in setup), or > create your test data through active record inside your test case.Jens, is there a way to explicitly turn off ferret during testing except for the functional tests where I want to test it? -- Posted via http://www.ruby-forum.com/.
On Sun, Dec 03, 2006 at 06:39:27PM +0100, Mark wrote: [..]> Jens, is there a way to explicitly turn off ferret during testing except > for the functional tests where I want to test it?No, none that I know of. But for sure it''s possible to hack something together that disables the indexing under certain conditions. Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66