" for filetype rspec
if !exists("*s:RunSpec")
function s:RunSpec()
let command="tmux send-keys -t bottom-left zeus " . "' '" . "rspec\ " . "' '" . expand("%") . ":" . line(".") . "$'\n'"
let g:last_spec_command=command
echo system(command)
endfunction
endif
nmap <buffer> T :call <SID>RunSpec()<CR>
" for filetype vim
if !exists("*s:RerunLastSpec")
function s:RerunLastSpec()
if exists("g:last_spec_command")
echo system(g:last_spec_command)
endif
endfunction
endif
nmap <buffer> T :call <SID>RerunLastSpec()<CR>
This assumes that your rspec files have a type of something like 'ruby.rspec'. An easy way to do this is as follows
augroup ExtraTypes
autocmd!
autocmd BufNewFile,BufRead *_spec.rb set ft+=.rspec
augroup end
With all this set up, T
in an rspec file will run the test on that line, and
in a ruby file will re-run the last test.
Note that it assumes a couple things:
- that the test command is zeus
- that you're in tmux and you want to run tests in the bottom-left pane.
It's easy enough to change the command to suit your environment.