class FactoryBot::DefinitionProxy
def association(name, *options)
name of the factory. For example, a "user" association will by
If no name is given, the name of the attribute is assumed to be the
The name of the factory to use when building the associated instance.
* factory: +Symbol+ or +String+
Options:
* options: +Hash+
The name of this attribute.
* name: +Symbol+
Arguments:
end
association :author, factory: :user
factory :post do
end
name 'Joey'
factory :user do
Example:
be built using the same build strategy as the parent instance.
Adds an attribute that builds an association. The associated instance will
def association(name, *options) if block_given? raise AssociationDefinitionError.new( "Unexpected block passed to '#{name}' association " \ "in '#{@definition.name}' factory" ) else declaration = Declaration::Association.new(name, *options) @definition.declare_attribute(declaration) end end