From 3bdba15fa57eb593327c638d86b54ae0e5817e39 Mon Sep 17 00:00:00 2001 From: Martin Ericson Date: Thu, 3 Aug 2023 21:35:45 +0200 Subject: [PATCH] Add support for factory_bot's default suffixed pattern --- lib/annotate/annotate_models/file_patterns.rb | 14 ++++++++------ .../annotate/annotate_models/file_patterns_spec.rb | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/annotate/annotate_models/file_patterns.rb b/lib/annotate/annotate_models/file_patterns.rb index f6cf3c0e7..baaf109a6 100644 --- a/lib/annotate/annotate_models/file_patterns.rb +++ b/lib/annotate/annotate_models/file_patterns.rb @@ -104,12 +104,14 @@ def factory_files(root_directory) File.join(root_directory, EXEMPLARS_SPEC_DIR, '%MODEL_NAME%_exemplar.rb'), File.join(root_directory, BLUEPRINTS_TEST_DIR, '%MODEL_NAME%_blueprint.rb'), File.join(root_directory, BLUEPRINTS_SPEC_DIR, '%MODEL_NAME%_blueprint.rb'), - File.join(root_directory, FACTORY_BOT_TEST_DIR, '%MODEL_NAME%_factory.rb'), # (old style) - File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%MODEL_NAME%_factory.rb'), # (old style) - File.join(root_directory, FACTORY_BOT_TEST_DIR, '%TABLE_NAME%.rb'), # (new style) - File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%TABLE_NAME%.rb'), # (new style) - File.join(root_directory, FACTORY_BOT_TEST_DIR, '%PLURALIZED_MODEL_NAME%.rb'), # (new style) - File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%PLURALIZED_MODEL_NAME%.rb'), # (new style) + File.join(root_directory, FACTORY_BOT_TEST_DIR, '%MODEL_NAME%_factory.rb'), # (old style) + File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%MODEL_NAME%_factory.rb'), # (old style) + File.join(root_directory, FACTORY_BOT_TEST_DIR, '%TABLE_NAME%.rb'), # (new style) + File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%TABLE_NAME%.rb'), # (new style) + File.join(root_directory, FACTORY_BOT_TEST_DIR, '%PLURALIZED_MODEL_NAME%.rb'), # (new style) + File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%PLURALIZED_MODEL_NAME%.rb'), # (new style) + File.join(root_directory, FACTORY_BOT_TEST_DIR, '%PLURALIZED_MODEL_NAME%_factory.rb'), # (new style) + File.join(root_directory, FACTORY_BOT_SPEC_DIR, '%PLURALIZED_MODEL_NAME%_factory.rb'), # (new style) File.join(root_directory, FABRICATORS_TEST_DIR, '%MODEL_NAME%_fabricator.rb'), File.join(root_directory, FABRICATORS_SPEC_DIR, '%MODEL_NAME%_fabricator.rb') ] diff --git a/spec/lib/annotate/annotate_models/file_patterns_spec.rb b/spec/lib/annotate/annotate_models/file_patterns_spec.rb index eabc1c5da..84752bfba 100644 --- a/spec/lib/annotate/annotate_models/file_patterns_spec.rb +++ b/spec/lib/annotate/annotate_models/file_patterns_spec.rb @@ -61,6 +61,8 @@ '/root/spec/factories/%TABLE_NAME%.rb', '/root/test/factories/%PLURALIZED_MODEL_NAME%.rb', '/root/spec/factories/%PLURALIZED_MODEL_NAME%.rb', + '/root/test/factories/%PLURALIZED_MODEL_NAME%_factory.rb', + '/root/spec/factories/%PLURALIZED_MODEL_NAME%_factory.rb', '/root/test/fabricators/%MODEL_NAME%_fabricator.rb', '/root/spec/fabricators/%MODEL_NAME%_fabricator.rb' ])