Module: FactoryGirl::Syntax::Methods
- Included in:
- Default, FactoryGirl::SyntaxRunner
- Defined in:
- lib/factory_girl/syntax/methods.rb
Overview
This module is a container for all strategy methods provided by FactoryGirl. This includes all the default strategies provided (#build, #create, #build_stubbed, and #attributes_for), as well as the complementary *_list methods.
Instance Method Summary collapse
-
#attributes_for(name, *traits_and_overrides, &block) ⇒ Hash
(see #strategy_method) Generates a hash of attributes for a registered factory by name.
-
#attributes_for_list(name, amount, *traits_and_overrides) ⇒ Array<Hash>
(see #strategy_method_list).
-
#build(name, *traits_and_overrides, &block) ⇒ Object
(see #strategy_method) Builds a registered factory by name.
-
#build_list(name, amount, *traits_and_overrides) ⇒ Array
(see #strategy_method_list).
-
#build_stubbed(name, *traits_and_overrides, &block) ⇒ Object
(see #strategy_method) Builds a stubbed registered factory by name.
-
#build_stubbed_list(name, amount, *traits_and_overrides) ⇒ Array
(see #strategy_method_list).
-
#create(name, *traits_and_overrides, &block) ⇒ Object
(see #strategy_method) Creates a registered factory by name.
-
#create_list(name, amount, *traits_and_overrides) ⇒ Array
(see #strategy_method_list).
-
#generate(name) ⇒ Object
Generates and returns the next value in a sequence.
-
#generate_list(name, count) ⇒ Object
Generates and returns the list of values in a sequence.
Instance Method Details
#attributes_for(name, *traits_and_overrides, &block) ⇒ Hash
(see #strategy_method) Generates a hash of attributes for a registered factory by name.
|
# File 'lib/factory_girl/syntax/methods.rb', line 49
|
#attributes_for_list(name, amount, *traits_and_overrides) ⇒ Array<Hash>
(see #strategy_method_list)
|
# File 'lib/factory_girl/syntax/methods.rb', line 66
|
#build(name, *traits_and_overrides, &block) ⇒ Object
(see #strategy_method) Builds a registered factory by name.
|
# File 'lib/factory_girl/syntax/methods.rb', line 33
|
#build_list(name, amount, *traits_and_overrides) ⇒ Array
(see #strategy_method_list)
|
# File 'lib/factory_girl/syntax/methods.rb', line 54
|
#build_stubbed(name, *traits_and_overrides, &block) ⇒ Object
(see #strategy_method) Builds a stubbed registered factory by name.
|
# File 'lib/factory_girl/syntax/methods.rb', line 44
|
#build_stubbed_list(name, amount, *traits_and_overrides) ⇒ Array
(see #strategy_method_list)
|
# File 'lib/factory_girl/syntax/methods.rb', line 62
|
#create(name, *traits_and_overrides, &block) ⇒ Object
(see #strategy_method) Creates a registered factory by name.
|
# File 'lib/factory_girl/syntax/methods.rb', line 39
|
#create_list(name, amount, *traits_and_overrides) ⇒ Array
(see #strategy_method_list)
|
# File 'lib/factory_girl/syntax/methods.rb', line 58
|
#generate(name) ⇒ Object
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)
90 91 92 |
# File 'lib/factory_girl/syntax/methods.rb', line 90 def generate(name) FactoryGirl.sequence_by_name(name).next end |
#generate_list(name, count) ⇒ Object
Generates and returns the list of values in a sequence.
Arguments:
name: (Symbol)
The name of the sequence that a value should be generated for.
count: (Fixnum)
Count of values
Returns:
The next value in the sequence. (Object)
104 105 106 107 108 |
# File 'lib/factory_girl/syntax/methods.rb', line 104 def generate_list(name, count) (1..count).map do FactoryGirl.sequence_by_name(name).next end end |