Sha256: f3e3f2707d6c01e465a1d302a1992aef40abd66007276d3ca8831ef3163194b5

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

require "minitest"

module Minitest
  module Checks
    class Base
      attr_accessor :minitest, :klass, :klass_hash, :where

      def self.run(data, minitest, ignore_methods)
        @minitest = minitest
        @ignore = [ignore_methods].flatten
        data.each do |klass, hash|
          @klass = klass
          @klass_hash = hash
          hash.each do |function, value|
            @where = "#{klass}##{function}"
            send(function, value)
          end
        end
      end

      def self.check_equal(expected, actual, msg = nil)
        expected = expected.sort.map(&:to_sym)
        actual = actual.sort.map(&:to_sym)
        msg = msg ? "#{@where}: #{msg}" : @where
        @minitest.assert_equal expected, actual, msg
      end

      def self.check_no_nil(actual, msg = nil)
        msg = msg ? "#{@where}: #{msg}" : @where
        @minitest.refute_nil actual, msg
      end

      def self.delete_methods(which)
        ignore2 = %i[attribute_aliases
          attributes_to_define_after_schema_loads column_headers
          default_scope_override]
        # cls -= %i[__callbacks helpers_path middleware_stack]
        # cls -= %i[attribute_type_decorations defined_enums]
        methods = @klass.send(which, false).sort
        methods.delete_if { |x| /^_/ =~ x }
        methods.delete_if { |x| /^(after|before|find_by)_/ =~ x }
        methods.delete_if { |x| /.*_associated_records_.*/ =~ x }
        methods2 = @klass.superclass.send(which, false).sort
        methods - methods2 - @ignore - ignore2
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mimoco-1.0.1 lib/mimoco_base.rb
mimoco-1.0.0 lib/mimoco_base.rb