Skip to content

Commit 3f3c153

Browse files
committed
:A in view now always tries for a spec or test
1 parent b9cb5fd commit 3f3c153

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

autoload/rails.vim

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,28 +2706,19 @@ function! s:AlternateFile()
27062706
else
27072707
let dest = f
27082708
endif
2709-
" Go to the (r)spec, helper, controller, or (mailer) model
2710-
let spec1 = fnamemodify(dest,':s?\<app/?spec/?')."_spec.rb"
2711-
let spec2 = fnamemodify(dest,':r:s?\<app/?spec/?')."_spec.rb"
2712-
let spec3 = fnamemodify(dest,':r:r:s?\<app/?spec/?')."_spec.rb"
2713-
let helper = fnamemodify(dest,':h:s?/views/?/helpers/?')."_helper.rb"
2714-
let controller = fnamemodify(dest,':h:s?/views/?/controllers/?')."_controller.rb"
2715-
let model = fnamemodify(dest,':h:s?/views/?/models/?').".rb"
2709+
let spec1 = fnamemodify(dest,':s?\<app/?spec/?')."_spec.rb"
2710+
let spec2 = fnamemodify(dest,':r:s?\<app/?spec/?')."_spec.rb"
2711+
let spec3 = fnamemodify(dest,':r:r:s?\<app/?spec/?')."_spec.rb"
27162712
if rails#app().has_file(spec1)
27172713
return spec1
27182714
elseif rails#app().has_file(spec2)
27192715
return spec2
27202716
elseif rails#app().has_file(spec3)
27212717
return spec3
2722-
elseif rails#app().has_file(helper)
2723-
return helper
2724-
elseif rails#app().has_file(controller)
2725-
let jumpto = expand("%:t:r")
2726-
return controller.'#'.jumpto
2727-
elseif rails#app().has_file(model)
2728-
return model
2718+
elseif rails#app().has('spec')
2719+
return spec2
27292720
else
2730-
return helper
2721+
return s:sub(s:sub(f,'<app/views/','test/functional/'),'/[^/]*$','_controller_test.rb')
27312722
endif
27322723
elseif t =~ '^controller-api\>'
27332724
let api = s:sub(s:sub(f,'/controllers/','/apis/'),'_controller\.rb$','_api.rb')

doc/rails.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ location in the file. For example, when editing a controller, the related
322322
file is template for the method currently being edited.
323323

324324
The easiest way to learn these commands is to experiment. A few examples of
325-
alternate and related files follow:
325+
alternate and related files for a Test::Unit application follow:
326326

327327
Current file Alternate file Related file ~
328328
model unit test schema definition
329329
controller (in method) functional test template (view)
330-
template (view) helper controller (jump to method)
330+
template (view) functional test controller (jump to method)
331331
migration previous migration next migration
332332
config/routes.rb config/database.yml config/environment.rb
333333

0 commit comments

Comments
 (0)