thoughtbot / factory_bot

A library for setting up Ruby objects as test data.
https://thoughtbot.com
MIT License
7.89k stars 2.6k forks source link

Fix docs about definition file paths #1626

Open r7kamura opened 4 months ago

r7kamura commented 4 months ago

The current implementation seems to load all definition files that match the following pattern in this order:

  1. factories.rb
  2. factories/**/*.rb
  3. test/factories.rb
  4. test/factories/**/*.rb
  5. spec/factories.rb
  6. spec/factories/**/*.rb

https://github.com/thoughtbot/factory_bot/blob/053ef4af1a7fd845bb8f5f9ae65967249c247617/lib/factory_bot/find_definitions.rb#L10-L24

There are several documents that mention definition file paths, but none of them are consistent with the current implementation. So I propose to first eliminate the gap between the documentation and the implementation in this pull request.

I would also be interested to know if this implementation is intentional or not, as it is important to know which files should be ideally scanned by rubocop-factory_bot.