thoughtbot / thoughtbot/factory_bot
How do you do inline association attribute overrides when your association doesnt match the factory name?
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 8.2k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
The docs here use the worst example where the association happens to match the factory:
https://github.com/thoughtbot/factory_bot/blob/main/GETTING_STARTED.md#overriding-attributes
factory :post do
# ...
author_last_name { "Writely" }
author { association :author, last_name: author_last_name }
end
What if "author" is called "previous_author" on the model, I've tried every variation of explicitly specify the factory and it doesn't work.
eg: previous_author factory: :author { ... } doesn't work, previous_author { ... factory: :author } doesn't work etc. Is this just not possible?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the overriding attributes section in GETTING_STARTED.md and reproduce the documented association example using a model attribute named previous_author and the :author factory. Check the existing documentation and tests for association overrides to determine the supported syntax. Done means the docs explain the correct form or clearly state that this case is unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100