Permalink
Browse files

Support direct mapping between app/* <-> test/*

In fact, I went as far as making it the first one on the list, so it's
hinted that it's the new way.
  • Loading branch information...
1 parent 5490142 commit 9b6bed029efd733a9870d5383ee04e3b46cef889 ☈king committed with Oct 25, 2012
Showing with 22 additions and 9 deletions.
  1. +22 −9 autoload/rails.vim
View
@@ -3182,27 +3182,40 @@ function! s:readable_related(...) dict abort
let file .= '_test.rb'
endif
if self.type_name('helper')
- return s:sub(file,'<app/helpers/','test/unit/helpers/')."\n".s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'<app/helpers/','spec/helpers/')
+ return s:sub(file,'<app/','test/')."\n".
+ \s:sub(file,'<app/helpers/','test/unit/helpers/')."\n".
+ \s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'<app/helpers/','spec/helpers/')
elseif self.type_name('model')
- return s:sub(file,'<app/models/','test/unit/')."\n".s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'<app/models/','spec/models/')
+ return s:sub(file,'<app/','test/')."\n".
+ \s:sub(file,'<app/models/','test/unit/')."\n".
+ \s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'<app/models/','spec/models/')
elseif self.type_name('controller')
- return s:sub(file,'<app/controllers/','test/functional/')."\n".s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'app/controllers/','spec/controllers/')
+ return s:sub(file,'<app/','test/')."\n".
+ \s:sub(file,'<app/controllers/','test/functional/')."\n".
+ \s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'app/controllers/','spec/controllers/')
elseif self.type_name('mailer')
- return s:sub(file,'<app/m%(ailer|odel)s/','test/unit/')."\n".s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'<app/','spec/')
+ " is %(|odel) necessary on that 2nd one ↓ ?
+ return s:sub(file,'<app/','test/')."\n".
+ \s:sub(file,'<app/m%(ailer|odel)s/','test/unit/')."\n".
+ \s:sub(s:sub(file,'_test\.rb$','_spec.rb'),'<app/','spec/')
elseif self.type_name('test-unit')
- return s:sub(s:sub(file,'test/unit/helpers/','app/helpers/'),'test/unit/','app/models/')."\n".s:sub(file,'test/unit/','lib/')
+ let app_helpered = s:sub(file,'test/unit/helpers/','app/helpers/')
+ return s:sub(app_helpered,'test/unit/','app/models/')."\n".
+ \s:sub(app_helpered,'<test/','app/')."\n".
+ \s:sub(file,'test/unit/','lib/')
elseif self.type_name('test-functional')
if file =~ '_api\.rb'
- return s:sub(file,'test/functional/','app/apis/')
+ return s:sub(file,'<test/functional/','app/apis/')
elseif file =~ '_controller\.rb'
- return s:sub(file,'test/functional/','app/controllers/')
+ return s:sub(file,'<test/functional/','app/controllers/')."\n".
+ \s:sub(file,'<test/','app/')
else
- return s:sub(file,'test/functional/','')
+ return s:sub(file,'<test/functional/','')
endif
elseif self.type_name('spec-lib')
return s:sub(file,'<spec/','')
elseif self.type_name('lib')
- return s:sub(f, '<lib/(.*)\.rb$', 'test/unit/\1_test.rb')."\n".s:sub(f, '<lib/(.*)\.rb$', 'spec/lib/\1_spec.rb')
+ return s:sub(f,'<lib/(.*)\.rb$','test/unit/\1_test.rb')."\n".s:sub(f,'<lib/(.*)\.rb$','spec/lib/\1_spec.rb')
elseif self.type_name('spec')
return s:sub(file,'<spec/','app/')
elseif file =~ '\<vendor/.*/lib/'

0 comments on commit 9b6bed0

Please sign in to comment.