Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs about definition file paths #1626

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

r7kamura
Copy link

@r7kamura r7kamura commented Feb 20, 2024

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

self.definition_file_paths = %w[factories test/factories spec/factories]
def self.find_definitions
absolute_definition_file_paths = definition_file_paths.map { |path| File.expand_path(path) }
absolute_definition_file_paths.uniq.each do |path|
load("#{path}.rb") if File.exist?("#{path}.rb")
if File.directory? path
Dir[File.join(path, "**", "*.rb")].sort.each do |file|
load file
end
end
end
end

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants