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

Version Path
classiccms-0.3.5 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classiccms-0.3.4 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classiccms-0.3.3 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classiccms-0.3.2 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classiccms-0.3.1 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classiccms-0.3.0 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classiccms-0.2.4.pre vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
challah-0.6.0 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
factory_girl-3.1.1 lib/factory_girl/syntax/make.rb
factory_girl-3.1.0 lib/factory_girl/syntax/make.rb
challah-0.5.4 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classicCMS-0.2.3 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classicCMS-0.2.2 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classicCMS-0.2.1 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classicCMS-0.2.0 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
classicCMS-0.1.2 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
challah-0.5.3 vendor/bundle/gems/factory_girl-3.0.0/lib/factory_girl/syntax/make.rb
factory_girl-3.0.0 lib/factory_girl/syntax/make.rb
factory_girl-3.0.0.rc1 lib/factory_girl/syntax/make.rb