1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Configure Your Test Database for Test Driven Development

The Ignored Test Database


If you haven't been using TDD with Rails, you've probably wondered what the test database in database.yml is. This is the configuration for the test database. Now that you're going to be using tests, you must configure it correctly.

The first thing to note is that it should not point to your production or development databases. The test database is created and destroyed often when running tests. If this points to a database already in use, it will be wiped out. Be sure you configure your test database to be its own database!

Using the default SQLite database configuration, the test portion of your database.yml should look something like this. This is also taken from the default database.yml, so if you've just generated your Rails project, this should already be created for you.

   adapter: sqlite3
   database: db/test.sqlite3
   pool: 5
   timeout: 5000
  1. About.com
  2. Technology
  3. Ruby
  4. Ruby on Rails
  5. Test-Driven Rails
  6. Configure Your Test Database for Test Driven Development

©2014 About.com. All rights reserved.