Ruben Laguna's blog

Jan 30, 2012 - 2 minute read - Comments

Sublime Text 2 RVM and RSpec

EDIT This post is obsolete. It has been superseeded by this newer post


I found out about Sublime Text 2 from the Ruby Rogues podcast, and I’m loving it. Although is has been a little problematic to set it up to honor my .rvmrc files and to run RSpec files from it.

First to get it to honor the .rvmrc project file you need to follow the instructions at this post . To make it easier for you I copied the instructions here: you must create a $HOME/bin/sublime_rvm.rb with the following content:

and make it executable with chmod +x ~/bin/sublime_rvm.rb then update your ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Ruby/Ruby.sublime-build to look like this:

After this you should be able to run a ruby file from Sublime Text 2 using Cmd-B and it will use whatever ruby version is specified in the .rvmrc for that project.

Having done that I created a ~/bin/sublime_rpec.rb file with the following content

and then I used Package Control to install RubyTest and modified ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/RubyTest/RubyTest.sublime-settings like this:

Of course you should point to your sublime_rspec.rb path which will differ from mine. And now when I press Cmd-Shift-R, Sublime Text will run the file with RSpec. Well in my case I prefer to run the RSpec test with the the bundled version of RSpec for the project, that’s why I use bundle exec rspec #{file} in the script. If you want to use the RSpec gem installed in your rvm gemset remove the bundle exec part.

Running a custom TestRunner from rake First steps in LUA-C++ integration