Created
September 9, 2012 21:29
-
-
Save qickstarter/3687430 to your computer and use it in GitHub Desktop.
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
" Rspec | |
let g:quickrun_config['ruby.rspec'] = { | |
\ 'type' : 'ruby.rspec', | |
\ 'command': 'rspec', | |
\ 'exec': 'bundle exec %c %o %s', | |
\ 'outputter' : 'rspec_outputter' | |
\} | |
let rspec_outputter = quickrun#outputter#buffer#new() | |
function! rspec_outputter.init(session) | |
call call(quickrun#outputter#buffer#new().init, [a:session], self) | |
endfunction | |
" syntax color | |
function! rspec_outputter.finish(session) | |
" 文字に色をつける。 | |
highlight default RSpecGreen ctermfg=White ctermbg=Green guifg=White guibg=Green | |
highlight default RSpecRed ctermfg=White ctermbg=Red guifg=White guibg=Red | |
call matchadd("RSpecGreen", "^[\.F]*\.[\.F]*$") | |
call matchadd("RSpecGreen", "^.*, 0 failures$") | |
call matchadd("RSpecRed", "F") | |
call matchadd("RSpecRed", "^.*, [1-9]* failures.*$") | |
call matchadd("RSpecRed", "^.*, 1 failure.*$") | |
call matchadd("RSpecRed", "^ *(.*$") | |
call matchadd("RSpecRed", "^ *expected.*$") | |
call matchadd("RSpecRed", "^ *got.*$") | |
call matchadd("RSpecRed", "Failure/Error:.*$") | |
call matchadd("RSpecRed", "^.*(FAILED - [0-9]*)$") | |
call matchadd("NonText", "Failures:") | |
call matchadd("NonText", "Finished") | |
call matchadd("NonText", "Failed") | |
call call(quickrun#outputter#buffer#new().finish, [a:session], self) | |
endfunction | |
call quickrun#register_outputter("rspec_outputter", rspec_outputter) | |
" ファイル名が_spec.rbで終わるファイルを読み込んだ時に上記の設定を自動で読み込む | |
function! RSpecQuickrun() | |
nmap <silent><buffer><Leader>lr :<C-U>QuickRun ruby.rspec.oneline<CR> | |
let b:quickrun_config = {'type' : 'ruby.rspec'} | |
" nnoremap <silent><buffer><Leader>lr :QuickRun ruby.rspec line('.')<CR> | |
nnoremap <expr><silent><buffer><Leader>lr "<Esc>:QuickRun ruby.rspec -cmdopt \"-l" . line('.') . "\"<CR>" | |
endfunction | |
au BufReadPost *_spec.rb call RSpecQuickrun() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment