Sha256: c87498d35c9598e7adb246a43246bb52997ee359cbb8fe657a4bca03ca46c2ea
Contents?: true
Size: 1.43 KB
Versions: 56
Compression:
Stored size: 1.43 KB
Contents
module FactoryGirl module Syntax module Default include Methods def define(&block) DSL.run(block) end def modify(&block) ModifyDSL.run(block) end class DSL def self.run(block) new.instance_eval(&block) end def factory(name, options = {}, &block) factory = 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 def sequence(name, *args, &block) FactoryGirl.register_sequence(Sequence.new(name, *args, &block)) end def trait(name, &block) FactoryGirl.register_trait(Trait.new(name, &block)) end end class ModifyDSL def self.run(block) new.instance_eval(&block) end def factory(name, options = {}, &block) factory = FactoryGirl.factory_by_name(name) proxy = FactoryGirl::DefinitionProxy.new(factory.definition.overridable) proxy.instance_eval(&block) end end end end extend Syntax::Default end
Version data entries
56 entries across 56 versions & 4 rubygems