Skip to content

Instantly share code, notes, and snippets.

@alterisian
Last active December 19, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alterisian/5883821 to your computer and use it in GitHub Desktop.
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!
#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