Skip to content

Instantly share code, notes, and snippets.

@kuboon
Created March 18, 2021 03:58
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 kuboon/6937ad7189066004a58681f294f6cc77 to your computer and use it in GitHub Desktop.
Save kuboon/6937ad7189066004a58681f294f6cc77 to your computer and use it in GitHub Desktop.
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