Rake Tasks

Hanami ships with default Rake tasks that can be used as prerequisites by developers to build their own tasks.

% bundle exec rake -T
rake environment # Load the full project
rake test        # Run tests (for Minitest)
rake spec        # Run tests (for RSpec)


Use this as a Rake task prerequisite when we need to access project code (eg. entities, actions, views, etc..)


Imagine we want to build a Rake task that is able to access project code (eg. a repository)

# Rakefile

task clear_users: :environment do
bundle exec rake clear_users

Test / Spec

This is the default Rake task, which runs the test suite

The following commands are equivalent:

% bundle exec rake
% bundle exec rake test

The :test (or :spec) Rake task is the default.

Ruby Server Hosting Ecosystem Compatibility

Many Software as a Service (SaaS) of the Ruby server hosting ecosystem are modeled after Ruby on Rails. For instance, Heroku expects to find the following Rake tasks in a Ruby application:

For Heroku, there isn't a way to customize the deploy, so we're supporting these "standard" Rake tasks from Ruby on Rails.

If you are in control of your deployment, don't rely on these Rake tasks, but please use hanami command line, instead.

Prev: Projects - Code Reloading
Next: Projects - Logging
Looking for Lotus? We renamed the project and it's now called Hanami. Read the announcement.