Skip to content

Instantly share code, notes, and snippets.

@vesh95
Forked from vkurennov/sphinx_helper.rb
Created March 12, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vesh95/91bee6e9f17da36b22b4a83bc8ca2924 to your computer and use it in GitHub Desktop.
Save vesh95/91bee6e9f17da36b22b4a83bc8ca2924 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'rails_helper'
RSpec.configure do |config|
config.use_transactional_fixtures = false
# DatabaseCleaner settings
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
# 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
DatabaseCleaner.strategy = :transaction
end
config.before(:each, sphinx: true) do
DatabaseCleaner.strategy = :truncation
# Index data when running an acceptance spec.
ThinkingSphinx::Test.index
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment