-
-
Save fabianoleittes/4155758 to your computer and use it in GitHub Desktop.
Using transactional DB cleanup
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 | |
require 'database_cleaner' | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with :truncation # Delete leftovers if any | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
end |
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/spec_helper.rb | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
RSpec.configure do |config| | |
config.mock_with :rspec | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment