1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_girl/syntax/default.rb
2011-01-26 20:44:24 -05:00

33 lines
805 B
Ruby

module FactoryGirl
module Syntax
module Default
include Methods
def define(&block)
DSL.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)
proxy.instance_eval(&block)
if parent = options.delete(:parent)
factory.inherit_from(FactoryGirl.factory_by_name(parent))
end
FactoryGirl.register_factory(factory)
end
def sequence(name, start_value = 1, &block)
FactoryGirl.sequences[name] = Sequence.new(start_value, &block)
end
end
end
end
extend Syntax::Default
end