Module: FactoryGirl::Syntax::Generate::ActiveRecord::ClassMethods Private

Defined in:
lib/factory_girl/syntax/generate.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#generate(overrides = {}) {|instance| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yields:

  • (instance)


43
44
45
46
47
48
49
# File 'lib/factory_girl/syntax/generate.rb', line 43

def generate(overrides = {}, &block)
  ActiveSupport::Deprecation.warn 'Model.generate is deprecated; use FactoryGirl.build(:name) instead.', caller
  instance = FactoryRunner.new(name.underscore, :build, [overrides]).run
  instance.save
  yield(instance) if block_given?
  instance
end

#generate!(overrides = {}) {|instance| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yields:

  • (instance)


51
52
53
54
55
56
# File 'lib/factory_girl/syntax/generate.rb', line 51

def generate!(overrides = {}, &block)
  ActiveSupport::Deprecation.warn 'Model.generate! is deprecated; use FactoryGirl.create(:name) instead.', caller
  instance = FactoryRunner.new(name.underscore, :create, [overrides]).run
  yield(instance) if block_given?
  instance
end

#spawn(overrides = {}) {|instance| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yields:

  • (instance)


58
59
60
61
62
63
# File 'lib/factory_girl/syntax/generate.rb', line 58

def spawn(overrides = {}, &block)
  ActiveSupport::Deprecation.warn 'Model.spawn is deprecated; use FactoryGirl.build(:name) instead.', caller
  instance = FactoryRunner.new(name.underscore, :build, [overrides]).run
  yield(instance) if block_given?
  instance
end