Rails testing with sqlite

Just a quick note with an answer to an issue which has been bugging me for days.

The problem

Tests run OK within Eclipse but fail miserably from the command line with an error like…

Started
...E
../lib/sqlite3/errors.rb:94:in `check': cannot rollback - no transaction is active (SQLite3::SQLException)

The diagnosis

It seems that the test runner automatically loads fixtures even if not asked to do so. The template fixture files contain stubs for test records which cause sqlite3 to choke.

The solution

Just make sure that fixture files actually contain real fixtures that are needed for your testing!

One thought on “Rails testing with sqlite

  1. I know this is an old post but this is the exact problem I was just having, so thank you for posting up your solution! Now I can write tests that run :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">