I have a rails app that uses Sunspot and Solr for search functionality. I'm currently writing functional tests (using Rails own test suite) to verify that when I call my searches controller with a search term in the params, the correct records are returned.
Currently I have:
test "should_return_some_records" do
get :index, :term => "search term here"
assert_response :success
assert more stuff ...
end
When I run rake test:functionals, this test bombs with a "ActionView::Template::Error", as Sunspot has returned an empty results array from its search block.
If I run rake sunspot:reindex
from within my setup method of my searches_controller_test, the test passes. However, this means that it action is also run for every test in that file, which makes things very slow.
Could someone give me a couple of pointers as to the best way to have Sunspot index my fixtures for my test environment, without having to do so before every single test.
Thanks muchly in advance.