Add an example of a trait used within a trait

Closes #518
This commit is contained in:
Olivier Lacan 2013-04-24 15:51:26 -03:00 committed by Joshua Clayton
parent fa9a81c166
commit 47c4d11afb
1 changed files with 18 additions and 0 deletions

View File

@ -695,6 +695,24 @@ end
# creates an admin user with name "John Doe"
FactoryGirl.create(:post).author
```
Finally, traits can be used within other traits to mix in their attributes.
```
FactoryGirl.define do
factory :order do
trait :completed do
completed_at { 3.days.ago }
end
trait :refunded do
completed
refunded_at { 1.day.ago }
end
end
end
```
Callbacks
---------