在 rspec 之前创建数据库和模式

Creating database & schema before rspec

我有一个 RoR 5 应用程序,它使用 MySQL 进行测试和开发。 MySQL 服务器创建了 development 数据库,但缺少 testing 数据库(因此规格不是 运行ning)。

我可以自己创建数据库,但我想知道是否有办法让 RoR 在我 运行 rspec spec.

时为我创建它

我会这样做:

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