TextMate
TextMate is a popular text editor for OS X. RSpec’s TextMate bundle has a big number of snippets for all of RSpec’s expectations, contexts and specify’s. You can even run specs from TextMate using CMD-R – and you’ll see a nice progress bar while the specs are running (except usually they run so fast you won’t be able to see it move).
If you select one or more directories or files you can run those too with CMD-R (but you have to have an arbitrary Ruby file open to make this work).
Installation
There are several ways to install the RSpec bundle for TextMate. We’ll start by the easiest.
Installing from RubyForge
Just download the tgz file from RubyForge, unpack it and double-click the RSpec.tmbundle icon. It is very important that your installed Ruby gem is a compatible version.
Installing from Subversion straight into your TextMate
cd ~/Library/Application\ Support/TextMate/Bundles/ svn co svn://rubyforge.org/var/svn/rspec/trunk/RSpec.tmbundle
Symlinking an existing RSpec.tmbundle Subversion checkout to TextMate
If you already have the RSpec trunk checked out somewhere, you should have the RSpec.tmbundle directory right under your working copy’s root directory.
All you need to do is to make a symbolic link from TextMate’s bundle directory to your working copy of the bundle:
ln -s path/to/rspec_trunk_checkout/RSpec.tmbundle ~/Library/Application\ Support/TextMate/Bundles/RSpec.tmbundle
Pointing to the right Ruby and RSpec.
You may need to adjust the PATH in your ~/.MacOSX/environment.plist file to point to the directory where your ruby and spec executables live. For example:
<key>PATH</key> <string>/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/usr/local/mysql/bin</string>
You may also have to set your TM_RUBY environment variable in TextMate’s preferences to point to your ruby executable.
You can also tell RSpec.tmbundle to use a particular RSpec (the library) at a particular location on your filesystem. Just define the TM_RSPEC_HOME environment variable in TextMate’s preferences. This should point to the your working copy’s rspec directory.
Setting RSpec command line options
You can specify these in the TM_RSPEC_OPTS environment variable in TextMate’s preferences.