Last active
December 19, 2015 02:29
-
-
Save alterisian/5883821 to your computer and use it in GitHub Desktop.
Test coverage: How many models have factories - not all will need them of course. I'm definately not implying that all of the models are going to need factories!
This file contains hidden or 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
#for running in the console | |
require 'factory_girl' | |
models = [] | |
factories = [] | |
#otherwise this list isn't going to contain all models. | |
Rails.application.eager_load! | |
ActiveRecord::Base.descendants.each do |model| | |
models << model.name | |
end | |
#Record the factories in use. Fac Records! | |
#(And exclude the subfactories indicated by _) | |
FactoryGirl.factories.each{ |fac| factories << fac.name.to_s.capitalize unless fac.name.to_s.include? "_" };nil | |
todo = models - factories | |
puts "We have #{models.count} models. We have #{factories.count}. Potentially we have #{todo.count} factories to create." | |
todo.sort.each{ |model| put model + "," } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment