Sha256: 1206f790cb8581e4abaa2f70b1430112a0165eddc76e34acd09e20a485b42776

Contents?: true

Size: 900 Bytes

Versions: 4

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

require "factory_bot"
require "factory_bot_rails/generator"
require "factory_bot_rails/reloader"
require "rails"

module FactoryBotRails
  class Railtie < Rails::Railtie
    config.factory_bot = ActiveSupport::OrderedOptions.new
    config.factory_bot.definition_file_paths = FactoryBot.definition_file_paths

    initializer "factory_bot.set_fixture_replacement" do
      Generator.new(config).run
    end

    initializer "factory_bot.set_factory_paths" do
      FactoryBot.definition_file_paths = definition_file_paths
    end

    initializer "factory_bot.register_reloader" do |app|
      Reloader.new(app, config).run
    end

    config.after_initialize do
      FactoryBot.find_definitions
    end

    private

    def definition_file_paths
      config.factory_bot.definition_file_paths.map do |path|
        Rails.root.join(path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
factory_bot_rails-5.0.1 lib/factory_bot_rails/railtie.rb
factory_bot_rails-5.0.0 lib/factory_bot_rails/railtie.rb
factory_bot_rails-5.0.0.rc2 lib/factory_bot_rails/railtie.rb
factory_bot_rails-5.0.0.rc1 lib/factory_bot_rails/railtie.rb