Search code examples
ruby-on-railsunit-testingtestingrake

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 ?


Solution

  • 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.