我猜这与Rake读取文件一次而不是倒带有关吗?但是,我不确定.有任何想法吗?
require 'rake' require 'rails_helper' describe 'MyRakeTask' do before(:all) do Rails.application.load_tasks end it 'does something sweet' do Rake::Task["namespace:my_task"].invoke # runs task end it 'but it doesnt do it again' do Rake::Task["namespace:my_task"].invoke # returns nil end end