Ruby on Rails

Create useful aliases for Rails development

Create useful aliases for Rails development February 16, 20181 Comment
Ruby on rails aliases

Sometimes typing long commands very often is quite annoying. There is a very simple solution for this. You can create an alias for given command which means that you can type your own command which would trigger another command.

Let’s say that every time you want to run your test suite you have to execute following code:

bundle exec rspec spec/models spec/controllers spec/helpers --format documentation

it will be a lot faster and easier to run tests by typing just this command:


Creating alias

Create new file, name it and put following command there:

alias run_tests='bundle exec rspec spec/models spec/controllers spec/helpers --format documentation'

Reload file in your console:


and you can run tests using your new and shorter command.

Of course, you may not want to create such file in main project directory because of other team members or any other reason. Instead of creating a new file you can edit your ~/.bashrc file and put all aliases there.

Photo by Tim Gouw from Pexels

Download free RSpec & TDD ebook

Do you want to earn more or jump to the next level in your company? Do you know that testing skills are one of the most desired skills? There is only first step: start testing and do it right. My ebook can help you. Subscribe to the newsletter to get a free copy of the book.

One comment

  1. Aliases are awesome. Two of my favorites are be=’bundle exec’ and r=’bin/rails’. For tests in particular though if you have rspec-rails installed bin/rake should run them and you might consider guard-rspec to for an even faster feedback loop. Cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *