Sha256: 01b1e0202119f08924db0d0786052fada4b27e1bbe38b203ea9461212e621870

Contents?: true

Size: 880 Bytes

Versions: 19

Compression:

Stored size: 880 Bytes

Contents

class ActiveSupport::TestCase
  def Build(*args) # rubocop:disable Style/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 Style/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

19 entries across 19 versions & 2 rubygems

Version Path
activerecord-import-1.4.0 test/support/generate.rb
activerecord-import-1.3.0 test/support/generate.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/activerecord-import-1.2.0/test/support/generate.rb
activerecord-import-1.2.0 test/support/generate.rb
activerecord-import-1.1.0 test/support/generate.rb
activerecord-import-1.0.8 test/support/generate.rb
activerecord-import-1.0.7 test/support/generate.rb
activerecord-import-1.0.6 test/support/generate.rb
activerecord-import-1.0.5 test/support/generate.rb
activerecord-import-1.0.4 test/support/generate.rb
activerecord-import-1.0.3 test/support/generate.rb
activerecord-import-1.0.2 test/support/generate.rb
activerecord-import-1.0.1 test/support/generate.rb
activerecord-import-1.0.0 test/support/generate.rb
activerecord-import-0.28.2 test/support/generate.rb
activerecord-import-0.28.1 test/support/generate.rb
activerecord-import-0.28.0 test/support/generate.rb
activerecord-import-0.27.0 test/support/generate.rb
activerecord-import-0.26.0 test/support/generate.rb