Open eregon opened 3 years ago
Thanks! Definitely worth exploring if we can inherit from BasicObject. I went down that path once with the DefinitionProxy (https://github.com/thoughtbot/factory_bot/pull/1144) and ended up turning back because it was going to break other things. Not sure what the situation is with the Evaluator.
Due to https://github.com/thoughtbot/factory_bot/blob/b223c275191985f776ff294825660fce98b3c0cc/lib/factory_bot/evaluator.rb#L10 methods like
singleton_method_added
(coming from BasicObject) are undefined.And then https://github.com/thoughtbot/factory_bot/blob/b223c275191985f776ff294825660fce98b3c0cc/lib/factory_bot/evaluator.rb#L81 will actually call
singleton_method_added
, and since the method is not there, will end up inmethod_missing
: https://github.com/thoughtbot/factory_bot/blob/b223c275191985f776ff294825660fce98b3c0cc/lib/factory_bot/evaluator.rb#L47-L51 which will forward it toSyntaxRunner.new
.singleton_method_added
does nothing by default so that's probably why this was never noticed.It's not necessarily a problem, but it also seems surprising.
Maybe FactoryBot::Evaluator should inherit from BasicObject, rather than undefine many methods, some of them which might have quite subtle effects like this?
I noticed this while investigating https://github.com/oracle/truffleruby/issues/2258.