Created
November 17, 2015 23:14
-
-
Save mkcode/9f3dc0a36b12eabe6643 to your computer and use it in GitHub Desktop.
This file contains 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
require 'chewy/rspec' | |
# Configure rspec to work with chewy | |
# | |
# By default, all chewy requests are ignored. This is important in case | |
# models (or factories by extension) contain after_commit hooks | |
# | |
# If a test or example group has chewy: true set on its metadata, then | |
# the example is run within the update strategy which immediately | |
# updates the index. Also, the index is purged before every test | |
# so that index tests work similarly to AR with DatabaseCleaner. | |
RSpec.configure do |config| | |
config.before(:suite) do | |
Chewy.strategy(:bypass) | |
end | |
config.around(:each, chewy: true) do |example| | |
Chewy.strategy(:urgent) do | |
Chewy.massacre | |
example.run | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment