Forum: Ruby on Rails How to write test cases for rake tasks.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vamsi K. (Guest)
on 2008-10-31 11:08
hi,

 i don't 've idea about how to write test cases for a rake task(rake
file)

 like i've a rake file named daily_summary.rake and i had written some
code like extracting from the database based on some criteria. and the
rake file is executed , its working fine.

        but i need to write test cases for this rake
file(daily_summary.rake)
 so any body can help me how to write test cases for rake file.


  Thanks
 Vamsi.
reHa (Guest)
on 2008-11-01 16:26
(Received via mailing list)
Hi there,

Facade design pattern?
Try to keep your rake files as simple as possible.
The best would be to extract all the logic to the separate lib file
and just call the logic from rake task.

task :daily_summary => :environment do
  #extract params
  day = ENV['DAY']
  DailySummary.process(day)
end

This way you can test your lib easily.
Cheers


On 31 Pa┬╝, 10:08, Vamsi K. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.