Sha256: 98c3315f279f292f7560183f5d07286dd4de950fe5fc61fd7cd2a6d5d204c55d
Contents?: true
Size: 1.02 KB
Versions: 59
Compression:
Stored size: 1.02 KB
Contents
module FactoryGirl module Syntax # Extends ActiveRecord::Base to provide a make class method, which is a # shortcut for FactoryGirl.create. # # Usage: # # require 'factory_girl/syntax/make' # # FactoryGirl.define do # factory :user do # name 'Billy Bob' # email 'billy@bob.example.com' # end # end # # User.make(name: 'Johnny') # # This syntax was derived from Pete Yandell's machinist. module Make module ActiveRecord #:nodoc: def self.included(base) # :nodoc: base.extend ClassMethods end module ClassMethods #:nodoc: def make(overrides = {}) FactoryRunner.new(name.underscore, Strategy::Build, [overrides]).run end def make!(overrides = {}) FactoryRunner.new(name.underscore, Strategy::Create, [overrides]).run end end end end end end ActiveRecord::Base.send(:include, FactoryGirl::Syntax::Make::ActiveRecord)
Version data entries
59 entries across 59 versions & 4 rubygems