On a freshly created Rails project (generated by rails someName
), one can run some 'default' rake tasks like:
rake test
rake db:migrate
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?
Rake enables you to define a set of tasks and the dependencies between them in a file, and then have the right thing happen when you run any given task. The combination of convenience and flexibility that Rake provides has made it the standard method of job automation for Ruby projects.
rake extension and are placed in Rails. root/lib/tasks . You can create these custom rake tasks with the bin/rails generate task command. If your need to interact with your application models, perform database queries and so on, your task should depend on the environment task, which will load your application code.
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks . Each task has a description, and should help you find the thing you need.
Rake is a popular task runner for Ruby and Rails applications. For example, Rails provides the predefined Rake tasks for creating databases, running migrations, and performing tests. You can also create custom tasks to automate specific actions - run code analysis tools, backup databases, and so on.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With