Usually tests are run inside a transaction. When debugging a failing test, it might be easier to inspect the data directly in the database. This is not possible within a transaction, because the data is not yet written.
To still debug such a test, it is possible to commit the current transaction. Set a debugger
breakpoint somewhere within a test, and then run:
You can then inspect the data in the database.
After debugging, do not forget to re-initialize your database (e.g. using bin/rails db:drop db:create
). Otherwise the committed data might interfere with your tests.