-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcwick-test.vim
More file actions
60 lines (50 loc) · 1.61 KB
/
Copy pathcwick-test.vim
File metadata and controls
60 lines (50 loc) · 1.61 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function! s:ExecWithClear(command)
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
exec a:command
endfunction
function! s:RunRSpec()
if filereadable("Gemfile")
let rspec_cmd = ":!bundle exec rspec --color"
else
let rspec_cmd = ":!rspec --color"
endif
call s:ExecWithClear(rspec_cmd)
let s:cwick_test = "s:RunRSpec"
endfunction
function! s:RunCucumber()
if filereadable("script/cucumber")
let cucumber_cmd = "script/cucumber"
else
let cucumber_cmd = "cucumber"
endif
call s:ExecWithClear(":!" . cucumber_cmd)
let s:cwick_test = "s:RunCucumber"
endfunction
function! s:UnknownTest()
echo "Sorry, I don't know how to test " . expand("%")
endfunction
function! s:RunLastTest()
if !exists("s:cwick_test")
let s:cwick_test = "s:UnknownTest"
endif
call function(s:cwick_test)()
endfunction
function! RunTests()
:wa
let current_file = expand("%")
if (match(current_file, '\.feature$') != -1) || (match(current_file, 'step_definitions/') != -1)
call s:RunCucumber()
elseif match(current_file, '_spec.rb$') != -1
call s:RunRSpec()
else
call s:RunLastTest()
end
endfunction