0
我試圖測試種子是否成功運行。我目前有以下幾種:使用minitest/rspec測試成功種子
require 'test_helper'
class SeedsTest < ActiveSupport::TestCase
test 'it should successfully run the seeds' do
assert_nothing_raised(Exception) { load Rails.root.join('db/seeds.rb') }
end
end
但是,load表達式只是返回true並且不會調用種子。 有沒有辦法做到這一點?
編輯: 我試圖運行它作爲耙測試,但它給了我一樣的。
assert_nothing_raised(Exception) { Rake::Task["db:seed"].invoke }