Sha256: fd6924b9ac4830b7a285b7a673e0ac60f4e90a80bea87278d0021cf00795d242

Contents?: true

Size: 806 Bytes

Versions: 18

Compression:

Stored size: 806 Bytes

Contents

module FactoryBot
  class << self
    # An Array of strings specifying locations that should be searched for
    # factory definitions. By default, factory_bot will attempt to require
    # "factories", "test/factories" and "spec/factories". Only the first
    # existing file will be loaded.
    attr_accessor :definition_file_paths
  end

  self.definition_file_paths = %w[factories test/factories spec/factories]

  def self.find_definitions
    absolute_definition_file_paths = definition_file_paths.map { |path| File.expand_path(path) }

    absolute_definition_file_paths.uniq.each do |path|
      load("#{path}.rb") if File.exist?("#{path}.rb")

      if File.directory? path
        Dir[File.join(path, "**", "*.rb")].sort.each do |file|
          load file
        end
      end
    end
  end
end

Version data entries

18 entries across 17 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot-6.5.0/lib/factory_bot/find_definitions.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot-6.5.0/lib/factory_bot/find_definitions.rb
factory_bot-6.5.0 lib/factory_bot/find_definitions.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/factory_bot-6.4.6/lib/factory_bot/find_definitions.rb
factory_bot-6.4.6 lib/factory_bot/find_definitions.rb
factory_bot-6.4.5 lib/factory_bot/find_definitions.rb
factory_bot-6.4.4 lib/factory_bot/find_definitions.rb
factory_bot-6.4.3 lib/factory_bot/find_definitions.rb
factory_bot-6.4.2 lib/factory_bot/find_definitions.rb
factory_bot-6.4.1 lib/factory_bot/find_definitions.rb
factory_bot-6.4.0 lib/factory_bot/find_definitions.rb
factory_bot-6.3.0 lib/factory_bot/find_definitions.rb
factory_bot-6.2.1 lib/factory_bot/find_definitions.rb
factory_bot-6.2.0 lib/factory_bot/find_definitions.rb
factory_bot-6.1.0 lib/factory_bot/find_definitions.rb
factory_bot-6.0.2 lib/factory_bot/find_definitions.rb
factory_bot-6.0.1 lib/factory_bot/find_definitions.rb
factory_bot-6.0.0 lib/factory_bot/find_definitions.rb