updated Getting Started with docu on new aliased sequence functionality

This commit is contained in:
Kristian Mandrup 2012-04-01 14:28:13 +02:00 committed by Joshua Clayton
parent 178a7ab3f4
commit f013335826
1 changed files with 29 additions and 0 deletions

View File

@ -401,6 +401,35 @@ factory :post do
end
```
Sequences can also have aliases. The sequence aliases share the same counter:
```ruby
factory :user do
sequence(:email, 1000, :aliases => [:sender, :receiver]) {|n| "person#{n}@example.com" }
end
# will increase value counter for :email which is shared by :sender and :receiver
FactoryGirl.next(:sender)
```
Define aliases and use default value (=1) for the counter
```ruby
factory :user do
sequence(:email, :aliases => [:sender, :receiver]) {|n| "person#{n}@example.com" }
end
```
Setting the value using the :value option:
```ruby
factory :user do
sequence(:email, :value => 'b', :aliases => [:sender, :receiver]) {|n| "person#{n}@example.com" }
end
```
The value just needs to support the `#next` method. Here the next value will be 'b'.
Traits
------