Where are rake tasks defined?

ryanprayogo picture ryanprayogo · Jan 20, 2011 · Viewed 21.9k times · Source

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

  • rake test
  • rake db:migrate
  • etc

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?

Answer

Adam Groves picture Adam Groves · Apr 4, 2013

If by described you mean defined, rake -W is your friend. Example:

$ rake -W db:create

=>

rake db:create  /path/to/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/railties/databases.rake:39:in `block in <top (required)>'

Just found this out today :)