How to load db:seed data into test database automatically?

How to load db:seed data into test database automatically?

Asked on January 12, 2019 in Ruby on Rails.
Add Comment


  • 2 Answer(s)

       The db:seed rake task primarily just loads the db/seeds.rb script execute that file to load the data.

    load "#{Rails.root}/db/seeds.rb"
    

    Using framework to be loaded before every test or just once at the beginning could put it in a setup call or in a test_helper.rb file.

    Answered on January 12, 2019.
    Add Comment

    Because db:test:load is not executed  have config.active_record.schema_format = :sql  db:test:clone_structure,

    namespace :db do
      namespace :test do
       task :prepare => :environment do
        Rake::Task["db:seed"].invoke
       end
      end
    end
    

    Answered on January 12, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.