Last active
December 14, 2015 04:08
-
-
Save starkcoffee/5025548 to your computer and use it in GitHub Desktop.
vim run current and last spec file, and run current spec for line number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! RunSpec(lineNumber) | |
wall | |
let lineNumberSpecified = a:lineNumber | |
let fname = expand("%") | |
if fname =~ "spec" | |
let g:spec = fname | |
let g:specLineNum = a:lineNumber | |
endif | |
if exists("g:spec") | |
let cmd = '!./script/spin ' . g:spec | |
if g:specLineNum && lineNumberSpecified | |
let cmd = cmd . ":" . g:specLineNum | |
endif | |
execute cmd | |
endif | |
endfunction | |
nmap <silent> ;r :call RunSpec("")<CR> | |
nmap <silent> ;l :call RunSpec(line("."))<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
-> add this to your .vimrc
-> replace ./script/spin with rspec .. I need to store the rspec function in a variable somewhere
-> put your cursor in the spec file and type either ;r to run the entire spec file or ;l to run the current spec under the cursor
-> you can move to other files and rerun these commands, and as long as you are not in another spec file, it will run the last command