Skip to content

Instantly share code, notes, and snippets.

@starkcoffee
Last active December 14, 2015 04:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starkcoffee/5025548 to your computer and use it in GitHub Desktop.
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
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>
@starkcoffee
Copy link
Author

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

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