検索が行われる場所で機能を実行しようとしています。私はThinkingSphinxのドキュメントがキュウリの機能でThinkingSphinxを検索すると結果が返されない
require 'cucumber/thinking_sphinx/external_world'
Cucumber::ThinkingSphinx::ExternalWorld.new
もトランザクションを使用して無効にし、代わりにDatabaseCleanersの切り捨てを使用することをお勧めします、必要な行を追加しました。私は機能設定をしているので、ユーザを追加した後、Sphinxのインデックスを更新してから検索します。
Scenario: Add a client to a project
Given I have a project named "ProjectXYZ"
And I have a client named "Tom Client" with an email address "[email protected]"
And the Sphinx indexes are updated
And if I search for "Tom" which is a "Client", I have 1 result
検索結果は、ユーザーがいても常に0を返します。 User.find_by_first_name( "Tom")のカウントをチェックするとcount.should eq(1)が成功します。ここで
は私の手順は次のとおりです。
更新インデックス
Given 'the Sphinx indexes are updated' do
# Update all indexes
ThinkingSphinx::Test.index
sleep(1.0) # Wait for Sphinx to catch up
end
検索とチェックの結果
Given /^if I search for "([^"]*)" which is a "([^"]*)", I have (\d+) results?$/ do |query,model,count|
Rails.const_get(model).search_count(query).should == count.to_i
end
私はRailsの3.0.3、キュウリ0.9.4を使用していますおよびキュウリ - レール0.3.2
スフィンクスがテストデータベースではなく開発データベースを検索していたことがわかります。助けてくれてありがとう、これは私を夢中にさせていた。 – ryanbillingsley
この回答に感謝します。たぶんこれは通常の問題のように思われるので、これを文書化してください。 – fuzzyalej
あなたはそれをどのように修正したのですか? – Edmund