Module Kernel
In: lib/mack-data_factory/core_extensions/kernel.rb

Methods

Public Instance methods

Convenient routine to create an execution chain of factories

Example:

  factories(:foo) do
    UserFactory.create(1)
    UserFactory.create(2, :diff_firstname)
  end

Then to execute the chains, you‘ll need to call run_factories, and pass in the name of the chain you want to execute.

  run_factories(:foo)

Parameters:

  tag: the name of the factory chain
  block: the proc to be executed later

[Source]

    # File lib/mack-data_factory/core_extensions/kernel.rb, line 28
28:   def factories(tag, &block)
29:     raise "factories: block needed" if !block_given?
30:     fact_registry.add(tag, block)
31:   end

Run defined factory chain defined using factories method.

Parameters:

  tag: the name of the factory chain to be run

[Source]

    # File lib/mack-data_factory/core_extensions/kernel.rb, line 39
39:   def run_factories(tag)
40:     runners = fact_registry.registered_items[tag]
41:     return false if runners == nil
42:     runners.each { |r| r.call }
43:     return true
44:   end

[Validate]