我正在尝试测试一个 rake 任务,它在其中使用了一个活动记录。
require 'spec_helper'
require 'rake'
load File.join(Rails.root, 'lib', 'tasks', 'survey.rake')
describe "survey rake tasks" do
describe "survey:send_report" do
it "should send a report" do
Rake::Task['survey:send_report'].invoke
end
end
end
当我运行此规范rspec spec/lib/survey_spec.rb
时,我收到此错误“
RuntimeError:
Don't know how to build task 'environment'
如何通过示例规范加载 :enviroment 任务?