ruby-on-railsrubyrakerakefile

Where are rake tasks defined?


On a freshly created Rails project (generated by rails someName), one can run some 'default' rake tasks like:

Question is, where does these tasks get described? The default Rakefile doesn't have all these tasks.

Furthermore, I checked out some project that uses rspec and I am able to run rake spec to run all the tests. Where does the spec target defined?


Solution

  • Rake tasks are automatically loaded from the folder structure lib/tasks/*.rake

    When we are talking about the task db:migrate for example, it is located within the rails gem in lib/tasks/databases.rake

    So for a specific project, you will always have the tasks within the project folder structure as well as all tasks within the specified gems.