Add documentation to using syntax methods inside dynamic attributes

Closes #355
This commit is contained in:
Ben Zhang and Josh Clayton 2012-04-20 16:15:09 -04:00 committed by Joshua Clayton
parent 29a5ab1a89
commit 3768d15322
1 changed files with 19 additions and 1 deletions

View File

@ -130,6 +130,24 @@ factory :user do
end
```
In addition to running other methods dynamically, you can use FactoryGirl's
syntax methods (like `build`, `create`, and `generate`) within dynamic
attributes without having to prefix the call with `FactoryGirl.`. This allows
you to do:
```ruby
sequence(:random_string) {|n| LoremIpsum.generate }
factory :post do
title { generate(:random_string) } # instead of FactoryGirl.generate(:random_string)
end
factory :comment do
post
body { generate(:random_string) } # instead of FactoryGirl.generate(:random_string)
end
```
Aliases
-------
@ -372,7 +390,7 @@ Or in lazy attributes:
```ruby
factory :invite do
invitee { FactoryGirl.generate(:email) }
invitee { generate(:email) }
end
```