Created
May 9, 2014 00:13
-
-
Save lkosak/8142ee47dc626928a718 to your computer and use it in GitHub Desktop.
vim rspec functions
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" RUNNING TESTS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
map <leader>r :call RunTestFile("")<cr> | |
"map <leader>r :call RunTestFile("", "--tag wip")<cr> | |
map <leader>t :call RunTestFile(line("."))<cr> | |
function! ZeusRunning() | |
return findfile(".zeus.sock", getcwd()) == ".zeus.sock" | |
endfunction | |
function! RunTestFile(line, ...) | |
let filename = expand("%") | |
if ZeusRunning() | |
let command = "zeus rspec" | |
else | |
let command = "bundle exec rspec" | |
end | |
let run = "" | |
if match(filename, '\.feature$') != -1 | |
let run = ":!cucumber " . filename | |
elseif match(filename, '_spec\.js$') != -1 | |
let run = ":!make test" | |
elseif match(filename, '_spec\.rb$') != -1 | |
if a:line | |
let filename = filename . ":" . a:line | |
endif | |
if a:0 > 0 | |
let run = ":!" . command . " " . a:1 . " " . filename | |
else | |
let run = ":!" . command . " " . filename | |
endif | |
end | |
if empty(run) | |
echo "Not in a test file" | |
else | |
exec run | |
endif | |
endfunction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment