Added support for Red/Green when specs pass/fail

This commit is contained in:
Christopher H. Laco 2011-02-09 01:09:17 -05:00
parent 36ae608e7d
commit 9d651daf08
1 changed files with 26 additions and 7 deletions

View File

@ -72,19 +72,38 @@ endfunction
function jasmine#run_tests()
let b:jasmine_root = jasmine#find_root()
execute "make --rakefile=\"".b:jasmine_rakefile."\" jasmine:ci"
echon "Running Jasmine tests..."
silent! let result = system("rake --rakefile=\"".b:jasmine_rakefile."\" jasmine:ci BACKGROUND=true")
redraw
let lines = split(result, "\n")
for line in lines
if line =~ '\d\+ examples, \(\d\+\) failure'
if line =~ ', 0 failure'
call jasmine#greenbar(line)
else
call jasmine#redbar(line)
endif
redraw
break
endif
endfor
endfunction
function jasmine#redbar()
hi RedBar ctermfg=white ctermbg=red guibg=red
function jasmine#redbar(message)
let message = " ".a:message
hi RedBar ctermfg=white ctermbg=red guifg=white guibg=red
echohl RedBar
echon repeat(" ",&columns - 1)
echon message repeat(" ", &columns - strlen(message) - 1)
echohl
endfunction
function jasmine#greenbar()
hi GreenBar ctermfg=white ctermbg=green guibg=green
function jasmine#greenbar(message)
let message = " ".a:message
hi GreenBar ctermfg=black ctermbg=green guifg=black guibg=green
echohl GreenBar
echon repeat(" ",&columns - 1)
echon message repeat(" ", &columns - strlen(message) - 1)
echohl
endfunction