aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/rspec.vim
blob: d2444761e473751947014cc50a09ecde4d666061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
fun! GetRubyBin()
    for [key, val] in items(g:ruby_bin_list)
        if match(expand("%:p"), key) == 0
            return val
        endif
    endfor
    return "ruby"
endfun

fun! GetSpecBin()
    for [key, val] in items(g:spec_bin_list)
        if match(expand("%:p"), key) == 0
            return val
        endif
    endfor
    return "spec"
endfun

fun! GetLibDirs()
    let l:lib_dirs = []
    for [key, val] in items(g:lib_dirs_list)
        if match(expand("%:p"), key) == 0
            call extend(l:lib_dirs, val)
        endif
    endfor
    return "-I\"".join(l:lib_dirs, "\" -I\"")."\""
endfun

fun! RunSpec()
    let l:current_file = expand("%:p")
    let l:ruby_bin = GetRubyBin()
    let l:spec_bin = GetSpecBin()
    let l:lib_dirs = GetLibDirs()
    let l:cmd = l:ruby_bin." ".l:lib_dirs." ".l:spec_bin." ".l:current_file
    exec "!".l:cmd
endfun