Running tests in Vim

@jferris In the latest Weekly Iteration, you were running your rests using t, I was just wondering how do you set that up?

Thanks

Hey @scott,

We wrote a Vim plugin for that: GitHub - thoughtbot/vim-rspec: Run Rspec specs from Vim

I have the recommended binding to run the current or last test, which is <Leader>t. My leader key is <Space>, because it’s a big, easy target and isn’t used for much in Normal Mode.

Thanks @jferris :slight_smile:

I use vim-rspec too and it is really awesome. You can run specs instantly, all specs, last specs, nearest spec… I really like it.

@jferris When watching the refactor, I sometimes found myself wondering how did you do something in regards to vim.

Would you guys consider doing something like a “Refactoring Ruby in Vim” where you point out nice tricks, alias, commands or macros you have that might come in handy?

@benorenstein

Have you checked out The Art of Vim in the Learn library? It covers exactly that sort of thing.

Also ‘Navigating Ruby Files in Vim’.

@benorenstein I’ve seen ‘Navigating Ruby Files in Vim’, I’ve not seen all of ‘The Art of Vim’. They are great and I’ve learnt a great deal, I was aiming at a more practical approach though.

Instead of saying “this is how you go from one method to the other”, say “I need to extract these 5 lines to a new method, here’s how you do that”.

Not sure if would be a good approach, just an idea. :wink:

I’ve got this in my .vimrc:

 " - Running rspec
map <Leader>ra :!rspec spec             " run all specs
map <Leader>rs :!rspec ./%:h/%:t        " run the spec in the current file

If you use the rs version, you can add “:[line number]” to run a specific spec

There are a series of posts on the thoughtbot blog on a few setup involving vim-rspec:

vim-rspec is really awesome, especially when combined with spring and a binstubbed rspec.

@jferris When I do leader a(well any of the commands), it is opening in terminal is there a way of getting it to run in iTerm2 ?

Thanks

There’s a pull request out for iTerm support: https://github.com/thoughtbot/vim-rspec/pull/25

@jferris I have put let g:rspec_command_launcher = "iterm" in my .vimrc but it is still opening in terminal :frowning:

@jferris Do I need to do something else?

Thanks

@scott for now, if you want to use iTerm support, you’ll need to use the branch on the legitscript fork: https://github.com/legitscript/vim-rspec/tree/iterm2-support

You’ll need to clone the repository, checkout the branch, and reference your local copy in your Vundle config.