Also keep in mind that SQLite does not support nested transactions.
So if your test starts a transaction (the default behavior) and then
your production code under test starts another transaction, the test
transaction rollback probably won’t work.

Also keep in mind that SQLite does not support nested transactions.
So if your test starts a transaction (the default behavior) and
then your production code under test starts another transaction,
the test transaction rollback probably won’t work.

Ah, this might be relevant.

My test is a pretty simple unit test for the Product model of Depot,
but maybe ActiveRecord is using some transaction behind the scenes.

If that was the case, why surprises me is that SQLite in-memory for
test is what rails(1) generates. If it does not work even in the
simplest of the tests it shouldn’t be there.

I have not been able to get the ‘sqlite3’ adapter to work, just using
‘sqlite’ should work. In addition, the sqlite adapter needs the
‘dbfile:’ argument rather than ‘database:’. Lastly, use “:memory”
instead of “:memory:”, omit the second colon. That made it work for
me.

The problem occurs when Rails attempts to rollback the transaction. It
seems like sqlite may be dropping the database (i.e. removing it from
memory) earlier than it should and thus when it comes time to close
the transaction, the database is already gone.

So as I understand it, because the test database is generated in a
separate
rake task, and it disappears once that task completes, the in-memory
database you get when you tests start to run is in fact a new, empty
database.

It would appear that the in-memory sqlite database example in
database.ymlis just a cruel hoax…