Created
May 7, 2014 16:42
-
-
Save lkosak/2e57922a5a4615c34d7a 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
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