Add info about list methods

This adds information about the `build_stubbed_list` and `attributes_for_list` methods as documented [here](http://www.rubydoc.info/github/thoughtbot/factory_girl/FactoryGirl/Syntax/Methods). These methods, like many things, helped me refactor out some less aesthetic code that did the same thing in my tests.
This commit is contained in:
Dave Shaffer 2016-08-11 11:12:54 -04:00 committed by Joshua Clayton
parent 8a65569f10
commit a1553a7439
No known key found for this signature in database
GPG Key ID: 5B6558F77E9A8118
1 changed files with 12 additions and 0 deletions

View File

@ -936,6 +936,12 @@ To set the attributes for each of the factories, you can pass in a hash as you n
twenty_year_olds = build_list(:user, 25, date_of_birth: 20.years.ago)
```
`build_stubbed_list` will give you fully stubbed out instances:
```ruby
stubbed_users = build_stubbed_list(:user, 25) # array of stubbed users
```
There's also a set of `*_pair` methods for creating two records at a time:
```ruby
@ -943,6 +949,12 @@ built_users = build_pair(:user) # array of two built users
created_users = create_pair(:user) # array of two created users
```
If you need multiple attribute hashes, `attributes_for_list` will generate them:
```ruby
users_attrs = attributes_for_list(:user, 25) # array of attribute hashes
```
Linting Factories
-----------------