mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Simplify trait assignment when constructing a factory
This commit is contained in:
parent
c38bac9d67
commit
3749056b3a
2 changed files with 1 additions and 9 deletions
|
@ -40,10 +40,10 @@ module FactoryGirl
|
|||
@parent_factory = nil
|
||||
@parent = options[:parent]
|
||||
@aliases = options[:aliases] || []
|
||||
@traits = options[:traits] || []
|
||||
@class_name = options[:class]
|
||||
@default_strategy = options[:default_strategy]
|
||||
@defined_traits = []
|
||||
@traits = []
|
||||
@children = []
|
||||
@attribute_list = AttributeList.new
|
||||
@compiled = false
|
||||
|
@ -71,10 +71,6 @@ module FactoryGirl
|
|||
@children << factory unless @children.include?(factory)
|
||||
end
|
||||
|
||||
def inherit_traits(traits)
|
||||
@traits = traits
|
||||
end
|
||||
|
||||
def define_trait(trait)
|
||||
@defined_traits << trait
|
||||
end
|
||||
|
|
|
@ -21,10 +21,6 @@ module FactoryGirl
|
|||
proxy = FactoryGirl::DefinitionProxy.new(factory)
|
||||
proxy.instance_eval(&block) if block_given?
|
||||
|
||||
if traits = options.delete(:traits)
|
||||
factory.inherit_traits(traits)
|
||||
end
|
||||
|
||||
if parent = options.delete(:parent)
|
||||
factory.inherit_factory(FactoryGirl.factory_by_name(parent))
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue