Created
July 1, 2015 08:54
-
-
Save gigorok/f61edd1f4c4f95082d6d to your computer and use it in GitHub Desktop.
find unused 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
module FactoryGirl | |
mattr_accessor :used_factories | |
self.used_factories = [] | |
def self.factory_by_name(name) | |
self.used_factories << name | |
factories.find(name) | |
end | |
def self.unused_factories | |
self.factories.map(&:name) - self.used_factories | |
end | |
end | |
RSpec.configure do |config| | |
config.after(:suite) do | |
if FactoryGirl.unused_factories.present? | |
puts "\nWARNING: You have #{FactoryGirl.unused_factories.count} unused factories: #{FactoryGirl.unused_factories}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment