Class: HasHelpers::FactoryScenario::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/has_helpers/factory_scenario/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_aliasesObject (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_nameObject (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_contextsObject (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

#nameObject (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_blockObject (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

#stepsObject (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