mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
b86ec136b6
to make use of did_you_mean gem. The did_you_mean gem only supports NameError, NoMethodError and KeyError. However, for NameError the message does also need to match a certain format and we can not use a custom message like 'Factory not registered ...'. Therefore using KeyError is to only logical conclusion. The did_you_mean gem makes use of the receiver attributes, but in Ruby > 2.5 it is not possible to set the receiver and key attributes on a KeyError (they are only set when the KeyError is raised in C). We explored monkey patching KeyError for earlier versions of Ruby, but it was a problematic solution. Instead we can rescue the original KeyError, take the message from it, which will already include the did_you_mean message, then customize the message and re-raise a new KeyError with that customized message. Starting in Ruby 2.6 this will not be necessary anymore https://bugs.ruby-lang.org/issues/14313, so maybe we can get rid of it for FactoryBot 6 or 7. Fixes #992 Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> |
||
---|---|---|
.. | ||
attribute | ||
declaration | ||
decorator | ||
strategy | ||
syntax | ||
aliases.rb | ||
attribute.rb | ||
attribute_assigner.rb | ||
attribute_list.rb | ||
callback.rb | ||
callbacks_observer.rb | ||
configuration.rb | ||
declaration.rb | ||
declaration_list.rb | ||
decorator.rb | ||
definition.rb | ||
definition_hierarchy.rb | ||
definition_proxy.rb | ||
errors.rb | ||
evaluation.rb | ||
evaluator.rb | ||
evaluator_class_definer.rb | ||
factory.rb | ||
factory_runner.rb | ||
find_definitions.rb | ||
linter.rb | ||
null_factory.rb | ||
null_object.rb | ||
registry.rb | ||
reload.rb | ||
sequence.rb | ||
strategy_calculator.rb | ||
strategy_syntax_method_registrar.rb | ||
syntax.rb | ||
syntax_runner.rb | ||
trait.rb | ||
version.rb |