Skip to content

Instantly share code, notes, and snippets.

@kuboon
Created Mar 18, 2021
Embed
What would you like to do?
RSpec prepare db
RSpec.shared_context 'prepare db' do
def records
raise 'caller should define'
end
before :all do
::ActiveRecord::Base.connection.begin_transaction(joinable: false)
records
end
after :all do
::ActiveRecord::Base.connection.rollback_transaction
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment