Emacs minor mode for Ruby test object generation libraries. Currently supports factory_girl and Fabrication and only under Rails (for now).
- inflections
- If you want to use the snippets you'll need YASnippet
v0.8.1
or greater
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.
C-c , j - Jump to the current buffer's model or factory
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 |
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 |
- Non-Rails projects
- More sophisticated snippets
Skye Shaw (skye.shaw AT gmail.com)