Sha256: eb9667e2f2c885d01880d4563b22b6cc29edaebe23f3d4bed2084b8f0665f8a8

Contents?: true

Size: 572 Bytes

Versions: 3

Compression:

Stored size: 572 Bytes

Contents

require "factory_bot_variants/variant_attributes"

module FactoryBotVariants
  module DSL
    STRATEGIES = [
      :build,
      :create,
      :attributes_for,
      :build_stubbed
    ].freeze

    STRATEGIES.each do |strategy|
      define_method("#{strategy}_variants") do |factory_name, *options|
        attributes = options.extract_options!

        VariantAttributes.map(attributes).map do |variant_attributes|
          ::FactoryBot.public_send(
            strategy, factory_name, *options, variant_attributes
          )
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
factory_bot_variants-0.3.0 lib/factory_bot_variants/dsl.rb
factory_bot_variants-0.2.0 lib/factory_bot_variants/dsl.rb
factory_bot_variants-0.1.0 lib/factory_bot_variants/dsl.rb