Ⅰ. 插件描述
Vim plugin for rapid navigation to FactoryBot factory definitionⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'christoomey/vim-rfactory'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'christoomey/vim-rfactory'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'christoomey/vim-rfactory'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/christoomey/vim-rfactory
Ⅳ. 文档说明
Rfactory 
Rfactory is a Vim plugin for rapid navigation to [FactoryBot][] factory
definitions within Vim, inspired by the navigation commands in [Rails.vim][].
![rfactory navigation demo][]
Usage
With your cursor anywhere on a line containing a FactoryBot reference, e.g.create(:user), run :Rfactory to navigate to the :user factory
definition.
If the current line contains a [FactoryBot trait][] reference,
you will be taken to the line that defines the trait within the parent
factory.
There are variants to the :Rfactory command to open the factories file in
your preferred split or tab configuration.
| Command | Action |
|---|---|
:Rfactory | :edit the file |
:RSfactory | :split the file |
:RVfactory | :vsplit the file |
:RTfactory | :tabedit the file |
:REfactory | (alias for :Rfactory) |
Requirements
Rfactory expects the factory file or files to be in one of the standard
factory file locations as specified in the [Defining Factories section][] of the
FactoryBot docs, specifically:
test/factories.rb
spec/factories.rb
test/factories/*.rb
spec/factories/*.rbSupport
The plugin does its best to support each of the FactoryBot methods,
specifically:
createbuildbuild_stubbedattributes_for
In addition, for each of the above methods, Rfactory also supports the<method>_pair and <method>_list variants (e.g. create_pair andcreate_list).