Auto-load the seed data from db/seeds.rb with rake

前端 未结 7 1335
谎友^
谎友^ 2020-12-14 08:17

I\'m using rails-rspec gem and I have several specs (models, controllers, etc). When I run:

bundle exec rake

everything is te

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 09:13

    I think we should use

    config.before(:each) do
      Rails.application.load_seed # loading seeds
    end
    

    as before(:all) runs the block one time before all of the examples are run.

    So if we use before :all, the seed data will be cleared.

提交回复
热议问题