diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 55f88447b..d33d7bb5f 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -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 ------