alexandernst alexandernst - 1 year ago 163
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

database created, but the
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 Source

I would do it like this:

RAILS_ENV=test bundle exec rake db:create 
RAILS_ENV=test bundle exec rake db:schema:load  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download