Method: Factory.sequence
- Defined in:
- lib/factory_girl/sequence.rb
.sequence(name, &block) ⇒ Object
Defines a new sequence that can be used to generate unique values in a specific format.
Arguments:
name: (Symbol)
A unique name for this sequence. This name will be referenced when
calling next to generate new values from this sequence.
block: (Proc)
The code to generate each value in the sequence. This block will be
called with a unique number each time a value in the sequence is to be
generated. The block should return the generated value for the
sequence.
Example:
Factory.sequence(:email) {|n| "somebody_#{n}@example.com" }
40 41 42 |
# File 'lib/factory_girl/sequence.rb', line 40 def self.sequence (name, &block) self.sequences[name] = Sequence.new(&block) end |