prajwaldp prajwaldp - 7 months ago 20
Ruby Question

Create a test environment database in ruby

I'm trying to build a ruby gem that uses active_record to connect to a database. How can I configure a separate test and regular database (like rails) so that the test database is used while running tests and the regular database is used otherwise?


Assuming you are using PostgreSQL, you would set it in your database.yml file:

  adapter: postgresql
  encoding: unicode
  database: app_test
  pool: 5
  username: username

You haven't explained what you mean by "regular database", but it could be development or production.

Then you have a second entry in the database.yml file for it.