1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 16:18:01 +00:00

Add Override The Initial Sequence Value as a ruby til.

This commit is contained in:
jbranchaud
2015-06-05 10:33:34 -05:00
parent 07ed19021b
commit 2159b74b03
2 changed files with 22 additions and 0 deletions

View File

@@ -80,6 +80,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
- [FactoryGirl Sequences](ruby/factory-girl-sequences.md) - [FactoryGirl Sequences](ruby/factory-girl-sequences.md)
- [Finding The Source of Ruby Methods](ruby/finding-the-source-of-ruby-methods.md) - [Finding The Source of Ruby Methods](ruby/finding-the-source-of-ruby-methods.md)
- [Limit Split](ruby/limit-split.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) - [Parallel Bundle Install](ruby/parallel-bundle-install.md)
- [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md) - [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md)
- [Summing Collections](ruby/summing-collections.md) - [Summing Collections](ruby/summing-collections.md)

View File

@@ -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"
```