我想测试rake任务中定义的方法。测试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任务中,以及...但我后面可能会担心。
请您详细说明一下吗?对不起,我无法关注 – Garfield
@Shikher,我做了一些实验,想出了一个更好的答案。看一看! –