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>
Closes#1033
> Arguably, association should raise and let the developer know
> they're using it in an unexpected way. I'd love to see a PR for
> that (with a test!), so if you're interested in contributing that,
> please do!
> https://github.com/thoughtbot/factory_girl/issues/1032#issuecomment-329297006
Co-authored-by: Daniel Colson <danieljamescolson@gmail.com>
This warning made sense when we had static attributes, since
somebody might try to write something like:
```rb
factory :composer do
self.name = "Daniel"
end
```
That would create a static declaration when the factory was defined,
then raise the error about avoiding writers when the factory was run.
Now this code will raise a NoMethodError right away when the factory is
being defined.