vim rfactory

Vim plugin for rapid navigation to FactoryBot factory definition

22
4
Ruby

Rfactory Build Status

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/*.rb

Support

The plugin does its best to support each of the FactoryBot methods,
specifically:

  • create
  • build
  • build_stubbed
  • attributes_for

In addition, for each of the above methods, Rfactory also supports the
<method>_pair and <method>_list variants (e.g. create_pair and
create_list).