class Yamatanooroti::TestCase

Public Class Methods

inherited(klass) click to toggle source
Calls superclass method
# File lib/yamatanooroti.rb, line 55
  def self.inherited(klass)
    super
    if ancestors.first == Yamatanooroti::TestCase
      if Yamatanooroti.has_vterm_gem?
        test_klass = Class.new(klass)
        klass.const_set(:TestVTerm, test_klass)
        test_klass.include Yamatanooroti::VTermTestCaseModule
        @@runners << test_klass
      end
      if Yamatanooroti.win?
        test_klass = Class.new(klass)
        klass.const_set(:TestWindows, test_klass)
        test_klass.include Yamatanooroti::WindowsTestCaseModule
        @@runners << test_klass
      end
      if @@runners.empty?
        raise LoadError.new(<<~EOM)
          Any real(?) terminal environments not found.
          Supporting real(?) terminals:
          - vterm gem
          - Windows
        EOM
      end
      def klass.method_added(name)
        super
        if ancestors[1] == Yamatanooroti::TestCase
          test_klass = @@runners.find { |test_klass| test_klass.ancestors.include?(self) }
          test_klass.define_method(name, instance_method(name))
          remove_method name
        end
      end
    end
  end