Module: FixtureValidation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/fixture_validation.rb,
lib/fixture_validation/engine.rb,
lib/fixture_validation/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
'0.2'
Instance Method Summary collapse
Instance Method Details
#test_validate_fixtures ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fixture_validation.rb', line 11 def test_validate_fixtures count = 0 klasses = [] fixture_table_names.each do |fixture_name| klass_name = fixture_name.classify begin klasses << klass_name.constantize rescue NameError Rails.logger.debug "No model class (#{klass_name}) found for fixture #{fixture_name}" end end errors = [] klasses.each do |klass| klass.all.each do |obj| errors << "Expected #{klass.to_s} fixture #{obj.id} to be valid. Errors: #{obj.errors.to_a.join(', ')}. Attribute values: #{obj.attributes.to_s}." unless obj.valid? count += 1 end end assert errors.empty?, "\n#{errors.join("\n")}" Rails.logger.debug "Validated #{count} fixtures" end |