← Back to Upcase

Running tests in Vim

(Scott Hollinshead) #1

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

Thanks

0 Likes

(Joe Ferris) #2

Hey @scott,

We wrote a Vim plugin for that: https://github.com/thoughtbot/vim-rspec

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.

0 Likes

(Scott Hollinshead) #3

Thanks @jferris :slight_smile:

0 Likes

(Patrik Bóna) #4

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.

0 Likes

(Luís Ferreira) #5

@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

0 Likes

(Ben Orenstein) #6

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’.

0 Likes

(Luís Ferreira) #7

@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:

0 Likes

(Jon Seidel) #8

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

0 Likes

(Joel Quenneville) #9

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

0 Likes

(Luís Ferreira) #10

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

0 Likes

(Scott Hollinshead) #11

@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

0 Likes

(Joe Ferris) #12

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

0 Likes

(Scott Hollinshead) #13

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

0 Likes

(Scott Hollinshead) #14

@jferris Do I need to do something else?

Thanks

0 Likes

(Joe Ferris) #15

@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.

0 Likes