There are already a lot of articles explaining how to setup an in memory SQLite database to speed up Rails specs or unit tests. Most of them explain how to change your database.yml and to run setup your schema before running the tests. It works fine.
There’s a catch though : suppose you are using cucumber, it’s likely you’d rather run cucumber on a real database (PostgreSQL, MySQL or whatever). Most gems expect cucumber and rspec to both run in the test environment … Every time I updated my bundle or that I wanted to use a new test gem, I would hit an issue about cucumber being run in its own ‘cucumber’ environment : unexpected warnings and things not working out of the box.
Eventually, I ditched the cucumber env, setup a PostgreSQL db on the test env, and injected the in memory sqlite database right inside spec_helper.rb :
In database.yml :
1 2 3 4 5 6 7 8 9 10
At the bottom of spec_helper.rb
1 2 3 4 5 6 7