Method: FactoryBot::Evaluator#association

Defined in:
lib/factory_bot/evaluator.rb

#association(factory_name, *traits_and_overrides) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/factory_bot/evaluator.rb', line 24

def association(factory_name, *traits_and_overrides)
  overrides = traits_and_overrides.extract_options!
  strategy_override = overrides.fetch(:strategy) {
    FactoryBot.use_parent_strategy ? @build_strategy.to_sym : :create
  }

  traits_and_overrides += [overrides.except(:strategy)]

  runner = FactoryRunner.new(factory_name, strategy_override, traits_and_overrides)
  @build_strategy.association(runner)
end