Rake is a Make-like program implemented in Ruby. It comes as a Rubygem and has to be included in your Gemfile during development. Custom Rake tasks start with a namespace followed by the task name separated by a colon. They reside in the
lib/tasks directory of a rails app and they go in a file with a .rake extension.
Here is the railsguides documentation on How to create Custom Rake tasks. Here is this good blog post by ANDREY KOLESHKO while I learnt about writing rake tasks. As you can see there you can either directly write the task in the
namespace.rake (remeber to name the file same as the namespace ) file in the
lib/tasksdirectory or you can use the rails generator to create the task file
$ rails g task my_namespace my_task
This will create a
lib/tasks/my_namespace.rake file where you can write your task.
I needed to run the two tasks
rake test and
Here is a custom task I wrote. It can run using
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|# rake test:all|
|namespace :test do|
|desc "Run rails and jasmine tests"|
|task :all do|
|puts "Running Rails tests"|
|puts "Running jasmine tests headlessly"|