Skip to content

Upgrading factory_bot 4 to 5

Breaking4.11.1 → 5.2.0Breaking5Deprecated3New4Changed5Fixed11

BreakingUpgrade verdict

5 breaking changes.

  • Removed: support for EOL versions of Ruby and Rails.
  • Removed: static attributes (use dynamic attributes with a block instead).
  • Removed: looking up factories by class.
  • Removed: ignore method (use transient instead).
Top 5 of 8 that need code or config changes

Ruby requirement changed in 5.0.0.rc1: >= 1.9.2 → >= 2.3.0.

Breaking5
Removed: support for EOL versions of Ruby and Rails.
Removed: static attributes (use dynamic attributes with a block instead).
Removed: looking up factories by class.
Removed: ignore method (use transient instead).
Removed: duplicate_attribute_assignment_from_initialize_with configuration option.
Deprecated3
Deprecated: top-level methods meant only for internal use: callbacks, configuration, constructor, initialize_with, register_sequence, resent_configuration, skip_create, to_create.
callbacksconfigurationconstructorinitialize_withregister_sequenceresent_configuration
Deprecated: top-level methods meant only for internal use: allow_class_lookup, allow_class_lookup=, register_trait, trait_by_name, traits, sequence_by_name, sequences, factory_by_name…
allow_class_lookupregister_traittrait_by_nametraitssequence_by_namesequences
Deprecated: allow_class_lookup configuration option.

Generated by DepDelta from published Ruby source. Not mixed with prose notes.

  • removed: static method FactoryBot.configuration()
  • removed: static method FactoryBot.factory_by_name(_)
  • removed: static method FactoryBot.register_callback(_)
  • removed: static method FactoryBot.register_default_callbacks()
  • removed: static method FactoryBot.register_default_strategies()
  • removed: static method FactoryBot.register_factory(_)
  • removed: static method FactoryBot.register_sequence(_)
  • removed: static method FactoryBot.register_strategy(_, _)
  • removed: static method FactoryBot.register_trait(_)
  • removed: static method FactoryBot.reset_configuration()
  • removed: static method FactoryBot.rewind_sequences()
  • removed: static method FactoryBot.sequence_by_name(_)
  • removed: static method FactoryBot.strategy_by_name(_)
  • removed: static method FactoryBot.trait_by_name(_)
  • added: static property FactoryBot.allow_class_lookup: accessor
  • removed: method Configuration.duplicate_attribute_assignment_from_initialize_with()
  • removed: method DefinitionHierarchy.callbacks()
  • removed: method DefinitionHierarchy.constructor()
  • removed: method DefinitionHierarchy.to_create()
  • removed: method DefinitionProxy.ignore()
  • removed: property Configuration.allow_class_lookup: accessor
  • removed: property Configuration.callback_names: reader
  • removed: property Configuration.factories: reader
  • removed: property Configuration.sequences: reader
  • removed: property Configuration.strategies: reader
  • removed: property Configuration.traits: reader
  • removed: property Configuration.use_parent_strategy: accessor
  • removed: set Configuration.duplicate_attribute_assignment_from_initialize_with(_)
  • changed: constructor Definition(_ = …, _ = …) → constructor Definition(_, _ = …)
  • changed: constructor Linter(_, _, _ = …) → constructor Linter(_, strategy: …, traits: …, verbose: …)
  • changed: method DefinitionProxy.add_attribute(_, _ = …) → method DefinitionProxy.add_attribute(_)
  • added: class Deprecation < ActiveSupport::Deprecation.new("6.0", "factory_bot")
  • added: class TraitDefinitionError < RuntimeError
  • added: module Internal
  • added: property Definition.name: reader
  • added: static method Internal.configuration()
  • added: static method Internal.factory_by_name(_)
  • added: static method Internal.register_callback(_)
  • added: static method Internal.register_default_callbacks()
  • added: static method Internal.register_default_strategies()
  • added: static method Internal.register_factory(_)
  • added: static method Internal.register_inline_sequence(_)
  • added: static method Internal.register_sequence(_)
  • added: static method Internal.register_strategy(_, _)
  • added: static method Internal.register_trait(_)
  • added: static method Internal.reset_configuration()
  • added: static method Internal.rewind_inline_sequences()
  • added: static method Internal.rewind_sequences()
  • added: static method Internal.sequence_by_name(_)
  • added: static method Internal.strategy_by_name(_)
  • added: static method Internal.trait_by_name(_)
  • added: static method StrategySyntaxMethodRegistrar.with_index(_, _)
  • removed: class NonAttributeWriterValidator
  • removed: class Static < Attribute
  • removed: constructor NonAttributeWriterValidator(_)
  • removed: constructor Static(_, _, _)
  • removed: method NonAttributeWriterValidator.validate!()
  • removed: method Static.to_proc()
  • removed: class Static < Declaration
  • removed: constructor Static(_, _, _ = …)
  • removed: method Static.==(_)
  • removed: protected property Static.value: reader
  • removed: class ClassKeyHash < Decorator
  • removed: method ClassKeyHash.[](_)
  • removed: method ClassKeyHash.[]=(_, _)
  • removed: method ClassKeyHash.key?(_)
  • added: method FactoryError.verbose_message()
  • removed: method ActiveModelDirtyBackport.clear_changes_information()
  • removed: module ActiveModelDirtyBackport
  • removed: method DSL.initialize_with()
  • removed: method DSL.skip_create()
  • removed: method DSL.to_create()