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