Created
November 12, 2013 11:34
-
-
Save danishsatkut/7429463 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SphinxHelpers | |
def index | |
ThinkingSphinx::Test.index | |
# Wait for Sphinx to finish loading in the new index files. | |
sleep 0.25 until index_finished? | |
end | |
def index_finished? | |
Dir[Rails.root.join(ThinkingSphinx::Test.config.searchd_file_path, '*.{new,tmp}.*')].empty? | |
end | |
end | |
RSpec.configure do |config| | |
config.include SphinxHelpers, type: :request | |
config.before(:suite) do | |
# Ensure sphinx directories exist for the test environment | |
ThinkingSphinx::Test.init | |
# Configure and start Sphinx, and automatically | |
# stop Sphinx at the end of the test suite. | |
ThinkingSphinx::Test.start_with_autostop | |
end | |
config.before(:each) do | |
# Index data when running an acceptance spec. | |
ThinkingSphinx::Test.index if example.metadata[:js] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment