module Spree::TestingSupport::FactoryBot
Constants
- FACTORIES
- PATHS
- SEQUENCES
Public Class Methods
add_definitions!()
click to toggle source
# File lib/spree/testing_support/factory_bot.rb, line 58 def self.add_definitions! ::FactoryBot.definition_file_paths.unshift(*definition_file_paths).uniq! end
add_paths_and_load!()
click to toggle source
# File lib/spree/testing_support/factory_bot.rb, line 62 def self.add_paths_and_load! add_definitions! ::FactoryBot.reload end
check_version()
click to toggle source
# File lib/spree/testing_support/factory_bot.rb, line 44 def self.check_version require "factory_bot/version" requirement = Gem::Requirement.new("~> 4.8") version = Gem::Version.new(::FactoryBot::VERSION) unless requirement.satisfied_by? version Spree::Deprecation.warn( "Please be aware that the supported version of FactoryBot is #{requirement}, " \ "using version #{version} could lead to factory loading issues.", caller(2) ) end end
definition_file_paths()
click to toggle source
# File lib/spree/testing_support/factory_bot.rb, line 16 def self.definition_file_paths @paths ||= PATHS.map { |path| path.sub(/.rb\z/, '') } end
deprecate_cherry_picking()
click to toggle source
# File lib/spree/testing_support/factory_bot.rb, line 32 def self.deprecate_cherry_picking callsites = caller core_root = Spree::Core::Engine.root.to_s index = callsites.index { |line| !line.start_with? core_root } Spree::Deprecation.warn( "Please do not cherry-pick factories, this is not well supported by FactoryBot, " \ 'follow the changelog instructions on how to migrate your current setup.', callsites[index..-1] ) end
when_cherry_picked() { || ... }
click to toggle source
# File lib/spree/testing_support/factory_bot.rb, line 20 def self.when_cherry_picked callsites = caller # All good if the factory is being loaded by FactoryBot or from `testing_support/factories.rb`. return if callsites.find do |line| line.include?("/factory_bot/find_definitions.rb") || line.include?("/spree/testing_support/factories.rb") end yield end