Skip to content

Latest commit

 

History

History
83 lines (59 loc) · 2.61 KB

README.md

File metadata and controls

83 lines (59 loc) · 2.61 KB

ruby-factory-mode

MELPA

Emacs minor mode for Ruby test object generation libraries. Currently supports factory_girl and Fabrication and only under Rails (for now).

Requirements

Usage

The preferred method of installation is via a package. ruby-factory-mode is available on MELPA.

To do things the old fashioned way:

(add-to-list 'load-path "/location/of/ruby-factory")
(require 'ruby-factory)

To enable the mode automatically add a ruby-mode-hook:

(add-hook 'ruby-mode-hook 'ruby-factory-mode)

If you're using RSpec it's recommended to use this with rspec-mode.

Key Bindings

C-c , j - Jump to the current buffer's model or factory

Snippets

factory_girl

Binding Snippet
aft `after :hook do
aftb `after :build do
aftc `after :create do
afts `after :stub do
bef `before :create do
fg FactoryGirl.define do ... end
fac factory :model do ... end
initw initialize_with { ... }
seq `sequence(:attribute) {
trai trait :attribute do ... end
tran transient do ... end

Fabrication

Binding Snippet
aft `after_hook do
aftb `after_build do
aftc `after_create do
aftv `after_validation do
bef `before_hook do
befc `before_create do
befs `before_save do
befv `before_validation do
fab Fabricator :model do ... end
initw initialize_with { ... }
seq `sequence(:attribute) {
tran transient :attribute

See Also

TODO

  • Non-Rails projects
  • More sophisticated snippets

Author

Skye Shaw (skye.shaw AT gmail.com)