Transactional Hanami tests
One of the things that you will likely do is to write request related specs on Hanami, by default, commits that happen on the DB are not transactional. Ideally we want tests to always be isolated from each other.
Now knowing that we use Sequel under the hood, this is what we can do in our spec_helper.rb in order to make our tests run in a transactional scope:
DB = Sequel.sqlite # change this according to the database you are using
RSpec.configure do |c|
c.around(:each) do |example|
DB.transaction(rollback: :always, auto_savepoint: true) {example.run}
end
end