0
0
Fork 0

Move RSpec config for streaming/search managers to be near classes (#27761)

This commit is contained in:
Matt Jankowski 2023-11-08 08:04:17 -05:00 committed by GitHub
parent ce91d14d48
commit b05575e242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 31 deletions

View file

@ -41,3 +41,38 @@ class SearchDataManager
Tag.destroy_all
end
end
RSpec.configure do |config|
config.before :suite do
if search_examples_present?
# Configure chewy to use `urgent` strategy to index documents
Chewy.strategy(:urgent)
# Create search data
search_data_manager.prepare_test_data
end
end
config.after :suite do
if search_examples_present?
# Clean up after search data
search_data_manager.cleanup_test_data
end
end
config.around :each, type: :search do |example|
search_data_manager.populate_indexes
example.run
search_data_manager.remove_indexes
end
private
def search_data_manager
@search_data_manager ||= SearchDataManager.new
end
def search_examples_present?
RUN_SEARCH_SPECS
end
end