| Module | FactoryGirl::Syntax::Vintage::Factory |
| In: |
lib/factory_girl/syntax/vintage.rb
|
Defines a new alias for attributes.
Arguments:
Example:
Factory.alias /(.*)_confirmation/, '\1'
factory_girl starts with aliases for foreign keys, so that a :user association can be overridden by a :user_id parameter:
Factory.define :post do |p|
p.association :user
end
# The user association will not be built in this example. The user_id
# will be used instead.
Factory(:post, :user_id => 1)
Executes the default strategy for the given factory. This is usually create, but it can be overridden for each factory.
DEPRECATED
Use create instead.
Arguments:
Returns: Object The result of the default strategy.
Defines a new factory that can be used by the build strategies (create and build) to build new objects.
Arguments:
Options:
Yields: Factory The newly created factory.
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" }