Sha256: 581e882f39791ab1ec2a5e622edc73591becae89bd32372a048339b9b9aca05d

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 Bytes

Contents

require "minitest"

module Minitest
  module Checks
    class Models < Base
      def self.class_methods(expected)
        meths = delete_methods(:methods)
        check_equal expected, meths
      end

      # call class methods; don't check result
      def self.call_class_methods(methods)
        methods.each { |meth|
          check_no_nil @klass.send(meth), "<#{meth}> should return no nil"
        }
      end

      def self.public_methods(expected)
        meths = delete_methods(:public_instance_methods)
        check_equal expected, meths
      end

      # call_public_methods; don't check result
      def self.call_public_methods(methods)
        klass_params = @klass_hash[:valid] || @klass_hash[:valids]&.first
        raise ValidMissingError unless klass_params

        methods.each { |meth|
          # row, _msg = @klass.create(klass_params)
          row = @klass.new(klass_params)
          check_no_nil row.send(meth), "<#{meth}> should return no nil"
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mimoco-1.0.3 lib/mimoco_models.rb
mimoco-1.0.2 lib/mimoco_models.rb
mimoco-1.0.1 lib/mimoco_models.rb