factory_girl
https://github.com/thoughtbot/factory_girl
Ruby
A library for setting up Ruby objects as test data.
FactoryGirl::DefinitionProxy#association
Adds an attribute that builds an association. The associated instance will
be built using the same build strategy as the parent instance.
Example:
factory :user do
name 'Joey'
end
factory :post do
association :author, factory: :user
end
Arguments:
* name: +Symbol+
The name of this attribute.
* options: +Hash+
Options:
* factory: +Symbol+ or +String+
The name of the factory to use when building the associated instance.
If no name is given, the name of the attribute is assumed to be the
name of the factory. For example, a "user" association will by
default use the "user" factory.Edit
git clone [email protected]:thoughtbot/factory_girl.git
cd factory_girl
open lib/factory_girl/definition_proxy.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-FactoryGirl--DefinitionProxy-association-for-pr
# Commit to gitgit add lib/factory_girl/definition_proxy.rbgit commit -m "better docs for FactoryGirl::DefinitionProxy#association"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-FactoryGirl--DefinitionProxy-association-for-pr
hub pull-request
# Celebrate!