Sha256: f489f1a21fdc8062deb34422cfac4334900a588fedb5c87d2abe9f68bb1dcae0
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
require 'fixture_validation/version' require 'active_support/concern' module FixtureValidation extend ActiveSupport::Concern included do fixtures :all end 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fixture_validation-0.2 | lib/fixture_validation.rb |