module FixtureFactory

Constants

VERSION

Private Class Methods

extract_attributes(object) click to toggle source
# File lib/fixture_factory.rb, line 33
def extract_attributes(object)
  raise ArgumentError, "FixtureFactory blocks must return a hash-like object" unless object.respond_to?(:to_h)
  object.to_h.symbolize_keys
end
retrieve(name, scope:, context: nil, overrides: {}) click to toggle source
# File lib/fixture_factory.rb, line 38
def retrieve(name, scope:, context: nil, overrides: {})
  definition = scope.all_factory_definitions.fetch(name) do
    raise NotFoundError, name
  end
  attributes = definition.run(context: context)
  attributes.merge!(overrides).delete(:id)
  [definition.klass, attributes]
end