Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created July 27, 2011 12:21
Show Gist options
  • Save slawosz/1109241 to your computer and use it in GitHub Desktop.
Save slawosz/1109241 to your computer and use it in GitHub Desktop.
Run single rspec spec in vim
map <F2> :<C-U>!bundle exec rspec <C-R>=expand("%:p") <CR> --drb -l <C-R>=line("'.") <CR> <CR>
map <C-F11> :call RunCurrentTest()<CR>
nmap <F11> :call RunLastTest()<CR>
nmap <F12> :!rspec <C-R>% --drb<CR>
function RunLastTest ()
if exists('w:current_test')
exe '!rspec ' . w:current_test . ' --drb'
else
call RunCurrentTest()
endif
endfunction
function RunCurrentTest ()
let w:current_test = expand("%:.") . ':' . line(".")
exe '!rspec ' . w:current_test . ' --drb'
endfunction
@lukaszkorecki
Copy link

I used to have this function - it runs rspec for

  • current line
  • whole file
  • everything

and opens a location list for easy navigation.... But then I started using guard :-)

@slawosz
Copy link
Author

slawosz commented Aug 24, 2011

@lukaszkorecki: I don't use guard, I described my test experience here: http://slawosz.github.com/2011/08/11/how-do-i-test-spork-and-emacs/

@lukaszkorecki
Copy link

Oh cool, I love reading how other people do this kind of thing. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment