Sunspot と Solr を使用して検索機能をテストするために、いつもの RSpec/Capybara リクエスト仕様を書きたいと思います。私は掘り下げてきましたが、これを機能させる方法が見つかりません。私は sunspot_test gem をインストールし、作成された製品が存在することを確認しました。問題はインデックス作成にあるようです。私は何が欠けていますか?
require 'spec_helper'
describe "search" do
context "when searching by name/description" do
let!(:super_mario_bros_3) { Factory(:product, :name => 'Super Mario Bros. 3') }
let!(:legend_of_zelda) { Factory(:product, :name => 'Legend of Zelda') }
before { Product.reindex; Sunspot.commit }
it "should only find games matching the search text", :js => true, :search => true do
# search_for fills in and submits the search form
search_for("Super")
# This yields an empty array
p Product.search { keyword "super" }.results
# These fail
page.should have_content super_mario_bros_3.name
page.should have_no_content legend_of_zelda.name
end
end
end