Just another Ruby on Rails weblog

rspec navigation using rails.vim

rspec, vim

Tim Pope hinted about adding custom Rcommands to supports navigation in rspec files with rails.vim plugin Something like :Rspecmodel, :Rspeccontroller, :Rspecview, :Rspechelper. Just add the following code in your .vimrc:

" RSpec navigation commands
autocmd User Rails Rcommand specmodel spec/models -glob=**/*
\-suffix=_spec.rb -default=model()
autocmd User Rails Rcommand spechelper spec/helpers -glob=**/*
\-suffix=_helper_spec.rb -default=controller()
autocmd User Rails Rcommand speccontroller spec/controllers -glob=**/*
\-suffix=_controller_spec.rb -default=controller()
autocmd User Rails Rcommand specview spec/views -glob=**/*
\-suffix=_view_spec.rb

You may customize :Rspecview command to match ‘html.erb’ suffix. And of course, :RSmodel, :RScontroller, etc. opens specs in split window.
See *rails-custom-navigation* and *rails-rspec* in docs

0 коментарів