---
title: Zsh completion for your tests and specs
teaser:
tags: web,unix,testing
author: Jason Morrison
published_on: 2009-09-11
---

Got zsh?  Loving your
[TATFT](http://smartic.us/2008/8/15/tatft-i-feel-a-revolution-coming-on/) but
tired of typing out all those spec commands?

    spec -cfs spec/controllers/application_controller_spec.rb

or test commands?

    ruby -Itest test/functionals/admin/users_controller_test.rb

Well, put away that keyboard oil, because you'll be saving keystrokes left and right!

    [~/dev/railsapp] $ spc a<Tab>
    admin/base_controller    application_controller  arrr_pirates_controller

    [~/dev/railsapp] $ spc app<Tab>
    admin/base_controller    application_controller  arrr_pirates_controller

    [~/dev/railsapp] $ spc application_controller<Enter>
    admin/base_controller    application_controller  arrr_pirates_controller

    spec -cfs spec/controllers/application_controller_spec.rb # ta-da!

You can also complete multiple tests or specs in one line.  Download the scripts
and find out more in [the zsh-rails-test-spec-shortcuts
repository](http://github.com/jasonm/zsh-rails-test-spec-shortcuts/).

![''](http://gardenpartyradio.com/wp/images/Sleeping-Bear.jpg)

_"I'm so tired of typing `ruby -Itest test/`... I'm so glad I installed the zsh
completion scripts.  I'll spend all my saved energy on eating campsites and
writing solid code!"_

## Bonus links

As a bonus, here's a reminder of an oldie but a goodie, **rake task completion**
for zsh:
http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh

And a recent one from the rubygems-developers list, for **gem command
completion** for zsh:
http://rubyforge.org/pipermail/rubygems-developers/2009-August/004860.html

## What about you

What's your favorite time saving alias, script, or shell completion?  Let us
know in the comments!
