Last active
July 1, 2022 02:53
-
-
Save kei-s/7d5d9d653e3784c6652b6324af27add7 to your computer and use it in GitHub Desktop.
Check unused FactoryBot definitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# brew install prce2 | |
# RAILS_ENV=test bin/rails r check_unused_factory_bot.rb | |
FactoryBot.factories.each do |factory| | |
command = %!pcregrep -Mr "(build|build_list|create|create_list)\\(\\n? *:#{factory.name}(,|\\))" spec! | |
result = `#{command}` | |
puts factory.name if result.chomp.empty? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment