“rake spec” migrates the database every time

前端 未结 3 1752
北荒
北荒 2021-01-26 11:10

When I run any of the rspec tasks via rake, the database seems to be dropped and migrated, but if I run them via script/spec path/to/spec, it doesn\'t. Is there an option I can

3条回答
  •  滥情空心
    2021-01-26 11:34

    I had this same problem also when running rspec from the command line. In my cases I was working with an legacy database that had no migrations, so the tests would fail because migrations could not be run.

    The solution was to edit the spec/spec_helper.rb file and delete the following line:

    ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
    

    After that the tests ran without failing.

提交回复
热议问题