Class: HasHelpers::FactoryScenario::Definition
- Inherits:
-
Object
- Object
- HasHelpers::FactoryScenario::Definition
- Defined in:
- lib/has_helpers/factory_scenario/definition.rb
Instance Attribute Summary collapse
-
#exposed_aliases ⇒ Object
readonly
Returns the value of attribute exposed_aliases.
-
#extends_name ⇒ Object
readonly
Returns the value of attribute extends_name.
-
#include_contexts ⇒ Object
readonly
Returns the value of attribute include_contexts.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#run_block ⇒ Object
readonly
Returns the value of attribute run_block.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #build(factory, as: nil, traits: [], default: {}, &block) ⇒ Object
-
#initialize(name, extends_name: nil) ⇒ Definition
constructor
A new instance of Definition.
- #run(&block) ⇒ Object
Constructor Details
#initialize(name, extends_name: nil) ⇒ Definition
Returns a new instance of Definition.
9 10 11 12 13 14 15 16 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 9 def initialize(name, extends_name: nil) @name = name @extends_name = extends_name @steps = [] @run_block = nil @include_contexts = [] @exposed_aliases = [] end |
Instance Attribute Details
#exposed_aliases ⇒ Object (readonly)
Returns the value of attribute exposed_aliases.
7 8 9 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 7 def exposed_aliases @exposed_aliases end |
#extends_name ⇒ Object (readonly)
Returns the value of attribute extends_name.
7 8 9 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 7 def extends_name @extends_name end |
#include_contexts ⇒ Object (readonly)
Returns the value of attribute include_contexts.
7 8 9 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 7 def include_contexts @include_contexts end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 7 def name @name end |
#run_block ⇒ Object (readonly)
Returns the value of attribute run_block.
7 8 9 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 7 def run_block @run_block end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
7 8 9 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 7 def steps @steps end |
Instance Method Details
#build(factory, as: nil, traits: [], default: {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 18 def build(factory, as: nil, traits: [], default: {}, &block) @steps << { factory: factory.to_sym, as: (as || factory).to_sym, traits: Array(traits).map(&:to_sym), default: default || {}, link_block: block } end |
#run(&block) ⇒ Object
28 29 30 |
# File 'lib/has_helpers/factory_scenario/definition.rb', line 28 def run(&block) @run_block = block end |