Skip to content

Instantly share code, notes, and snippets.

@entp
Created June 19, 2009 19:34
Show Gist options
  • Save entp/132823 to your computer and use it in GitHub Desktop.
Save entp/132823 to your computer and use it in GitHub Desktop.
module ThinkingSphinx
def self.index_documents_in_testing
ThinkingSphinx::Deltas::Job.cancel_thinking_sphinx_jobs
config = ThinkingSphinx::Configuration.instance
config.build
FileUtils.mkdir_p config.searchd_file_path
cmd = "#{config.bin_path}indexer --config #{config.config_file} --all"
cmd << " --rotate" if ThinkingSphinx.sphinx_running?
File.open(File.join(Rails.root, 'log', 'test_sphinx_output.log'), 'a+') do |f|
f << cmd
Open3.popen3 cmd do |stdin, stdout, stderr|
f << stdout.read
f << stderr.read
end
f << '...'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment