Class: FactoryGirl::Syntax::Default::DSL
- Inherits:
-
Object
- Object
- FactoryGirl::Syntax::Default::DSL
- Defined in:
- lib/factory_girl/syntax/default.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run(block) ⇒ Object
11 12 13 |
# File 'lib/factory_girl/syntax/default.rb', line 11 def self.run(block) new.instance_eval(&block) end |
Instance Method Details
#factory(name, options = {}, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/factory_girl/syntax/default.rb', line 15 def factory(name, = {}, &block) factory = Factory.new(name, ) proxy = FactoryGirl::DefinitionProxy.new(factory) proxy.instance_eval(&block) if block_given? if parent = .delete(:parent) factory.inherit_from(FactoryGirl.factory_by_name(parent)) end FactoryGirl.register_factory(factory) proxy.child_factories.each do |(child_name, , child_block)| factory(child_name, .merge(:parent => name), &child_block) end end |
#sequence(name, start_value = 1, &block) ⇒ Object
29 30 31 |
# File 'lib/factory_girl/syntax/default.rb', line 29 def sequence(name, start_value = 1, &block) FactoryGirl.register_sequence(Sequence.new(name, start_value, &block)) end |