Created
February 12, 2013 19:35
-
-
Save jparker/4772677 to your computer and use it in GitHub Desktop.
Mappings and a function for running RSpec within Vim.
This file contains hidden or 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
noremap <Leader>rs :call RunSpec('spec', '-fp')<CR> | |
noremap <Leader>rd :call RunSpec(expand('%:h'), '-fd')<CR> | |
noremap <Leader>rf :call RunSpec(expand('%'), '-fd')<CR> | |
noremap <Leader>rl :call RunSpec(expand('%'), '-fd -l ' . line('.'))<CR> | |
function! RunSpec(spec_path, spec_opts) | |
let speccish = match(@%, '_spec.rb$') != -1 | |
if speccish | |
exec '!bundle exec rspec ' . a:spec_opts . ' ' . a:spec_path | |
else | |
echo '<< WARNING >> RunSpec() can only be called from inside spec files!' | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment