Created
January 13, 2016 05:41
-
-
Save vraravam/b302e808b04753858ba4 to your computer and use it in GitHub Desktop.
If using database_cleaner gem in a rails app....
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
# spec/support/database_cleaner.rb | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each, js: true) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
Role.find_or_create_by!(name: Role::PAINTER) | |
Role.find_or_create_by!(name: Role::SALESMAN) | |
# moved to 'truncation' since we are using the after_save hook to trigger the stored proc on various models | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each, type: :feature) do | |
DatabaseCleaner.strategy = :truncation unless Capybara.current_driver == :rack_test | |
end | |
config.before(:each, :truncation_mode) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.append_after(:each) do | |
DatabaseCleaner.clean | |
Role.find_or_create_by!(name: Role::PAINTER) | |
Role.find_or_create_by!(name: Role::SALESMAN) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment