Skip to content

Commit

Permalink
updated Getting Started with docu on new aliased sequence functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup authored and joshuaclayton committed Apr 6, 2012
1 parent 178a7ab commit f013335
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions GETTING_STARTED.md
Expand Up @@ -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
------

Expand Down

0 comments on commit f013335

Please sign in to comment.