This module is a container for all strategy methods provided by FactoryGirl. This includes all the default strategies provided ({Methods#build}, {Methods#create}, {Methods#build_stubbed}, and {Methods#attributes_for}), as well as the complementary *_list methods. @example singular factory execution
# basic use case build(:completed_order) # factory yielding its result to a block create(:post) do |post| create(:comment, post: post) end # factory with attribute override attributes_for(:post, title: "I love Ruby!") # factory with traits and attribute override build_stubbed(:user, :admin, :male, name: "John Doe")
@example multiple factory execution
# basic use case build_list(:completed_order, 2) create_list(:completed_order, 2) # factory with attribute override attributes_for_list(:post, 4, title: "I love Ruby!") # factory with traits and attribute override build_stubbed_list(:user, 15, :admin, :male, name: "John Doe")
Generates and returns the next value in a sequence.
Arguments:
name: (Symbol) The name of the sequence that a value should be generated for.
Returns:
The next value in the sequence. (Object)
# File lib/factory_girl/syntax/methods.rb, line 90 def generate(name) FactoryGirl.sequence_by_name(name).next end