Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write unit test cases for rake tasks in rails?

Hi all I have this situation , I need to write unit test cases for rake tasks in my rails application but i could not figure out a way to do that. Did any one try that ?

like image 590
Deepak Avatar asked Dec 30 '25 11:12

Deepak


1 Answers

What you can do is this..

  1. Write your logic which will run on a rake task inside a model or class.

  2. Write unit test for that model.

  3. Finally call that method inside your rake task.

like image 102
rajibchowdhury Avatar answered Jan 01 '26 02:01

rajibchowdhury



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!