A Day in the Life

2008-06-17

vim-rails を rspec に対応

おおー便利。すばらしい。是非本家に取り込んで貰ってほしいですね。

以下 git origin/master (git://git.tpope.net/git/vim-rails.git) との diff。github なら pull request 楽なのになー。

diff --git a/autoload/rails.vim b/autoload/rails.vim
index 811d7cc..df01f96 100644
--- a/autoload/rails.vim
+++ b/autoload/rails.vim
@@ -1777,6 +1777,9 @@ function! s:BufFinderCommands()
   call s:addfilecmds("unittest")
   call s:addfilecmds("functionaltest")
   call s:addfilecmds("integrationtest")
+  call s:addfilecmds("spec")
+  call s:addfilecmds("speccontroller")
+  call s:addfilecmds("specmodel")
   call s:addfilecmds("stylesheet")
   call s:addfilecmds("javascript")
   call s:addfilecmds("task")
@@ -1945,6 +1948,14 @@ function! s:pluginList(A,L,P)
   endif
 endfunction

+function! s:speccontrollerList(A,L,P)
+  return s:autocamelize(s:relglob("spec/controllers/",s:recurse,"_controller_spec.rb"),a:A)
+endfunction
+
+function! s:specmodelList(A,L,P)
+  return s:autocamelize(s:relglob("spec/models/",s:recurse,"_spec.rb"),a:A)
+endfunction
+
 " Task files, not actual rake tasks
 function! s:taskList(A,L,P)
   let top = s:relglob("lib/tasks/",s:recurse,".rake")
@@ -2316,6 +2327,26 @@ function! s:integrationtestEdit(bang,cmd,...)
   return s:EditSimpleRb(a:bang,a:cmd,"integrationtest",f,"test/integration/","_test.rb")
 endfunction

+function! s:specEdit(bang,cmd,...)
+  if s:model() != ''
+    let f = s:model()
+    return s:EditSimpleRb(a:bang,a:cmd,"spec",f,"spec/models/","_spec.rb")
+  else
+    let f = s:controller()
+    return s:EditSimpleRb(a:bang,a:cmd,"spec",f,"spec/controllers/","_controller_spec.rb")
+  endif
+endfunction
+
+function! s:speccontrollerEdit(bang,cmd,...)
+  let f = s:controller()
+  return s:EditSimpleRb(a:bang,a:cmd,"speccontroller",f,"spec/controllers/","_controller_spec.rb")
+endfunction
+
+function! s:specmodelEdit(bang,cmd,...)
+  let f = s:model()
+  return s:EditSimpleRb(a:bang,a:cmd,"specmodel",f,"spec/models/","_spec.rb")
+endfunction
+
 function! s:pluginEdit(bang,cmd,...)
   let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
   let plugin = ""

缶コーヒー

がコーンスープの味がするように思えてきた。コクが煮てる?

記事の一覧 >