Skip to content

Instantly share code, notes, and snippets.

@yevgenko
Created December 31, 2017 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yevgenko/53f80b1d5c173f4aaa16b990130a25be to your computer and use it in GitHub Desktop.
Save yevgenko/53f80b1d5c173f4aaa16b990130a25be to your computer and use it in GitHub Desktop.
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