Sha256: da505eed770ee529083ebc51ca4f13c229178b0c1126ee9c61a54a1f4fca262d

Contents?: true

Size: 687 Bytes

Versions: 5

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

require "factory_bot"
begin
  require "factory_bot_rails"
rescue LoadError
end

module SolidusLegacyPromotions
  module TestingSupport
    module FactoryBot
      FACTORIES = Dir["#{::SolidusLegacyPromotions::Engine.root}/lib/solidus_legacy_promotions/testing_support/factories/**/*_factory.rb"].sort

      def self.definition_file_paths
        @paths ||= FACTORIES.map { |path| path.sub(/.rb\z/, '') }
      end

      def self.add_definitions!
        ::FactoryBot.definition_file_paths.unshift(*definition_file_paths).uniq!
      end

      def self.add_paths_and_load!
        add_definitions!
        ::FactoryBot.reload
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_legacy_promotions-4.5.1 lib/solidus_legacy_promotions/testing_support/factory_bot.rb
solidus_legacy_promotions-4.5.0 lib/solidus_legacy_promotions/testing_support/factory_bot.rb
solidus_legacy_promotions-4.4.2 lib/solidus_legacy_promotions/testing_support/factory_bot.rb
solidus_legacy_promotions-4.4.1 lib/solidus_legacy_promotions/testing_support/factory_bot.rb
solidus_legacy_promotions-4.4.0 lib/solidus_legacy_promotions/testing_support/factory_bot.rb