Sha256: 5bdbf110b7c9b18ce307dee726c2c7fc110da8daa5fe28d4ba0e93710c8162c9

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

# frozen_string_literal: true

require_relative "all_records_validator/version"

module RSpec
  module AllRecordsValidator
    def self.validate!(ignored_models: [], only_has_many: false)
      target_classes = ApplicationRecord.subclasses.reject {|klass| klass.abstract_class? || ignored_models.include?(klass) || (only_has_many && klass.reflect_on_all_associations(:has_many).blank?) }

      target_classes.each do |klass|
        klass.all.find_each do |obj|
          obj.validate!
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-all_records_validator-0.1.0 lib/rspec/all_records_validator.rb