Permalink
Browse files

updated Getting Started with docu on new aliased sequence functionality

  • Loading branch information...
1 parent 61e6a9c commit 88511f1142f62f7096ea6da3f801f539f32edab2 @kristianmandrup committed Apr 1, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 GETTING_STARTED.md
View
29 GETTING_STARTED.md
@@ -405,6 +405,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
------

0 comments on commit 88511f1

Please sign in to comment.