Skip to content

Instantly share code, notes, and snippets.

@kuboon
Created March 18, 2021 03:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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