1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_bot/errors.rb
Sweta 5ccc564923
Fix self referencing trait error (#1294)
If a new trait is defined with attributes,  check if attributes matches the name of
the trait. Raise an error if so, to avoid a recursive call to the
trait.

Co-authored-by: Daniel Colsen <daniel.j.colson@thoughtbot.com>
Co-authored-by: Paras Sanghavi <sanghaviparas@gmail.com>
2019-09-10 16:24:20 -07:00

28 lines
1.1 KiB
Ruby

module FactoryBot
# Raised when a factory is defined that attempts to instantiate itself.
class AssociationDefinitionError < RuntimeError; end
# Raised when a trait is defined that references itself.
class TraitDefinitionError < RuntimeError; end
# Raised when a callback is defined that has an invalid name
class InvalidCallbackNameError < RuntimeError; end
# Raised when a factory is defined with the same name as a previously-defined factory.
class DuplicateDefinitionError < RuntimeError; end
# Raised when attempting to register a sequence from a dynamic attribute block
class SequenceAbuseError < RuntimeError; end
# Raised when defining an attribute twice in the same factory
class AttributeDefinitionError < RuntimeError; end
# Raised when attempting to pass a block to an association definition
class AssociationDefinitionError < RuntimeError; end
# Raised when a method is defined in a factory or trait with arguments
class MethodDefinitionError < RuntimeError; end
# Raised when any factory is considered invalid
class InvalidFactoryError < RuntimeError; end
end