78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/baja.rb', line 78
def factory(name, options = {}, &block)
puts "path: #{FactoryLoad.path}"
options[:class] = name.to_s.gsub(/_list/,'') unless options.has_key?(:class)
name = :"#{@namespace}___#{name.to_s}" unless @namespace.nil?
puts name
factory = FactoryGirl::Factory.new(name, options)
proxy = FactoryGirl::DefinitionProxy.new(factory.definition)
proxy.instance_eval(&block) if block_given?
FactoryGirl.register_factory(factory)
proxy.child_factories.each do |(child_name, child_options, child_block)|
parent_factory = child_options.delete(:parent) || name
factory(child_name, child_options.merge(parent: parent_factory), &child_block)
end
end
|