From 2159b74b03af7af46612fc1538d97e78a5b5fc30 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 5 Jun 2015 10:33:34 -0500 Subject: [PATCH] Add Override The Initial Sequence Value as a ruby til. --- README.md | 1 + ruby/override-the-initial-sequence-value.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ruby/override-the-initial-sequence-value.md diff --git a/README.md b/README.md index db93108..580537d 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [FactoryGirl Sequences](ruby/factory-girl-sequences.md) - [Finding The Source of Ruby Methods](ruby/finding-the-source-of-ruby-methods.md) - [Limit Split](ruby/limit-split.md) +- [Override The Initial Sequence Value](ruby/override-the-initial-sequence-value.md) - [Parallel Bundle Install](ruby/parallel-bundle-install.md) - [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md) - [Summing Collections](ruby/summing-collections.md) diff --git a/ruby/override-the-initial-sequence-value.md b/ruby/override-the-initial-sequence-value.md new file mode 100644 index 0000000..0297538 --- /dev/null +++ b/ruby/override-the-initial-sequence-value.md @@ -0,0 +1,21 @@ +# Override The Initial Sequence Value + +[FactoryGirl sequences](https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#sequences) +can be defined with an initial starting value + +```ruby +FactoryGirl.define do + sequence :email, 1000 do |n| + "person#{n}@example.com" + end +end +``` + +thus: + +```ruby +> FactoryGirl.generate :email +=> "person1000@example.com" +> FactoryGirl.generate :email +=> "person1001@example.com" +```