我想测试 rake 任务中定义的方法。
耙文件
#lib/tasks/simple_task.rake
namespace :xyz do
task :simple_task => :environment do
begin
if task_needs_to_run?
puts "Lets run this..."
#some code which I don't wish to test
...
end
end
end
def task_needs_to_run?
# code that needs testing
return 2 > 1
end
end
现在,我想task_needs_to_run?
在测试文件中测试这个方法,我该怎么做?
附加说明:理想情况下,我还希望在 rake 任务中测试另一个私有方法......但我稍后会担心。