Class: FactoryTrace::CheckUnused
- Inherits:
-
Object
- Object
- FactoryTrace::CheckUnused
- Defined in:
- lib/factory_trace/check_unused.rb
Instance Method Summary collapse
- #check! ⇒ Array<Hash>
-
#initialize(data) ⇒ CheckUnused
constructor
A new instance of CheckUnused.
Constructor Details
#initialize(data) ⇒ CheckUnused
Returns a new instance of CheckUnused.
5 6 7 |
# File 'lib/factory_trace/check_unused.rb', line 5 def initialize(data) @initial_data = data end |
Instance Method Details
#check! ⇒ Array<Hash>
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/factory_trace/check_unused.rb', line 10 def check! data = prepare(initial_data) output = [] FactoryBot.factories.each do |factory| unless data[factory.name.to_s] output << {code: :unused, factory: factory} next end factory.defined_traits.each do |trait| output << {code: :unused, factory: factory, trait: trait} unless data[factory.name.to_s].include?(trait.name.to_s) end end FactoryBot.traits.each do |trait| output << {code: :unused, trait: trait} unless data['_traits'].include?(trait.name.to_s) end output end |