alexandernst alexandernst - 1 month ago 16
Ruby Question

Creating database & schema before rspec

I have a RoR 5 app which uses MySQL for testing and development. The MySQL server has a

development
database created, but the
testing
database is missing (thus specs aren't running).

I could create the database on my own, but I'm wondering if there is a way I can make RoR create it for me when I run
rspec spec
.

Answer

I would do it like this:

RAILS_ENV=test bundle exec rake db:create 
RAILS_ENV=test bundle exec rake db:schema:load  
Comments