Skip to content

Instantly share code, notes, and snippets.

@sfsekaran
Forked from samg/.vimrc.vim
Created April 6, 2011 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfsekaran/906568 to your computer and use it in GitHub Desktop.
Save sfsekaran/906568 to your computer and use it in GitHub Desktop.
Execute focused specs from vim; Detects bundler.
" Execute open rspec buffer
" Thanks to Ian Smith-Heisters
function! RunSpec(args)
if exists("b:rails_root")
if filereadable(b:rails_root . "/Gemfile")
let spec = "bundle exec rspec"
elseif filereadable(b:rails_root . "/script/spec")
let spec = b:rails_root . "/script/spec"
else
let spec = "rspec"
end
end
let cmd = ":! " . spec . " % -cfn " . a:args
execute cmd
endfunction
" Mappings
" run one rspec example or describe block based on cursor position
map !s :call RunSpec("-l " . <C-r>=line('.')<CR>)
" run full rspec file
map !S :call RunSpec("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment