Created
December 31, 2017 05:06
-
-
Save yevgenko/53f80b1d5c173f4aaa16b990130a25be 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 'active_record' | |
require 'database_cleaner' | |
require 'yaml' | |
connection_info = YAML.load(ERB.new(File.read("config/database.yml")).result)["test"] | |
ActiveRecord::Base.establish_connection(connection_info) | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :transaction | |
DatabaseCleaner.clean_with(:truncation) | |
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