Skip to content

FactoryBot::DefinitionProxy: remove definition attr_reader#1752

Merged
neilvcarvalho merged 2 commits intothoughtbot:mainfrom
CodeMeister:definition-proxy-definition-method-renamed
Jun 3, 2025
Merged

FactoryBot::DefinitionProxy: remove definition attr_reader#1752
neilvcarvalho merged 2 commits intothoughtbot:mainfrom
CodeMeister:definition-proxy-definition-method-renamed

Conversation

@CodeMeister
Copy link
Contributor

@CodeMeister CodeMeister commented Jun 2, 2025

Fixes: #1751

A new attr_reader :definition was added to FactoryBot::DefinitionProxy.

When trying to set an instance attribute named :definition using :method_missing, it's targeting the proxy :definition rather than creating an attribute, leading to an exception

I've removed the :instance method and changed all references to @instance

🤔

:definition was added as an attr_reader but raises an exception when
a model with an attribute called :definition is set via :method_missing.

Renaming to :root_definition solves this issue.
@CodeMeister
Copy link
Contributor Author

Hi @neilvcarvalho, this is a simpler solution & one that avoids any potential attribute naming conflict.

😀

@neilvcarvalho
Copy link
Member

Thanks @CodeMeister!

@neilvcarvalho neilvcarvalho changed the title FactoryBot::DefinitionProxy: renamed :definition to :root_definition. FactoryBot::DefinitionProxy: remove definition attr_reader Jun 3, 2025
@neilvcarvalho neilvcarvalho merged commit 931283f into thoughtbot:main Jun 3, 2025
25 checks passed
@CodeMeister CodeMeister deleted the definition-proxy-definition-method-renamed branch July 28, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undocumented breaking change in 6.5.3 for attributes named definition

2 participants