aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorMatt Singleton <matthew.j.singleton@gmail.com>2011-02-26 23:33:17 -0500
committerMatt Singleton <matthew.j.singleton@gmail.com>2011-02-26 23:33:17 -0500
commitaf1fce1b01852c3d5bf7514ea4984c3f6b0474e6 (patch)
tree1e79d2edc3973c1f38985d692760dece4cdc180c /vim
parent5e26c2063f933961c670aa47f0ad8102a7600f4b (diff)
vim plugin for running rspec on the current file
Diffstat (limited to 'vim')
-rw-r--r--vim/plugin/rspec.vim36
1 files changed, 36 insertions, 0 deletions
diff --git a/vim/plugin/rspec.vim b/vim/plugin/rspec.vim
new file mode 100644
index 0000000..d244476
--- /dev/null
+++ b/vim/plugin/rspec.vim
@@ -0,0 +1,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