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 タスクで別のプライベート メソッドもテストしたいと思います...しかし、後で心配することができます。