Sha256: f5d8bb537d3c7fcc08e549778037461852642f6ede03b9c63b2c26d3e415f021

Contents?: true

Size: 913 Bytes

Versions: 7

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

class ActiveSupport::TestCase
  def Build(*args) # rubocop:disable Naming/MethodName
    n = args.shift if args.first.is_a?(Numeric)
    factory = args.shift
    factory_bot_args = args.shift || {}

    if n
      [].tap do |collection|
        n.times.each { collection << FactoryBot.build(factory.to_s.singularize.to_sym, factory_bot_args) }
      end
    else
      FactoryBot.build(factory.to_s.singularize.to_sym, factory_bot_args)
    end
  end

  def Generate(*args) # rubocop:disable Naming/MethodName
    n = args.shift if args.first.is_a?(Numeric)
    factory = args.shift
    factory_bot_args = args.shift || {}

    if n
      [].tap do |collection|
        n.times.each { collection << FactoryBot.create(factory.to_s.singularize.to_sym, factory_bot_args) }
      end
    else
      FactoryBot.create(factory.to_s.singularize.to_sym, factory_bot_args)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-import-2.0.0 test/support/generate.rb
activerecord-import-1.8.1 test/support/generate.rb
activerecord-import-1.8.0 test/support/generate.rb
activerecord-import-1.6.0 test/support/generate.rb
activerecord-import-1.5.1 test/support/generate.rb
activerecord-import-1.5.0 test/support/generate.rb
activerecord-import-1.4.1 test/support/generate.rb