rubygem/lib/zeus/m.rb
def suites
        # Since we're not using `ruby -Itest -Ilib` to run the tests, we need to add this directory to the `LOAD_PATH`
        $:.unshift "./test", "./lib"

        if framework == :testunit1
          Test::Unit::TestCase.class_eval {
            @@test_suites = {}
            def self.inherited(klass)
              @@test_suites[klass] = true
            end
            def self.test_suites
              @@test_suites.keys
            end
            def self.test_methods
              public_instance_methods(true).grep(/^test/).map(&:to_s)
            end
          }
        end

        begin
          # Fire up the Ruby files. Let's hope they actually have tests.
          @files.each { |f| load f }
        rescue LoadError => e
          # Fail with a happier error message instead of spitting out a backtrace from this gem
          abort "Failed loading test file:\n#{e.message}"
        end

        # Figure out what test framework we're using
        case framework
        when :minitest5
          suites = Minitest::Runnable.runnables
        when :minitest_old
          suites = MiniTest::Unit::TestCase.test_suites
        when :testunit1, :testunit2
          suites = Test::Unit::TestCase.test_suites
        else
          not_supported
        end

        # Use some janky internal APIs to group test methods by test suite.
        suites.inject({}) do |suites, suite_class|
          # End up with a hash of suite class name to an array of test methods, so we can later find them and ignore empty test suites
          test_methods = case framework
          when :minitest5
            suite_class.runnable_methods
          else
            suite_class.test_methods
          end
          suites[suite_class] = test_methods if test_methods.size > 0
          suites
        end
      end
# Finds all test suites in this test file, with test methods included.
Finds all test suites in this test file, with test methods included.
Finds all test suites in this test file with test methods included .
def suites
        $:.unshift "./test", "./lib"
        if framework == :testunit1
          Test::Unit::TestCase.class_eval {
            @@test_suites = {}
            def self.inherited(klass)
              @@test_suites[klass] = true
            end
            def self.test_suites
              @@test_suites.keys
            end
            def self.test_methods
              public_instance_methods(true).grep(/^test/).map(&:to_s)
            end
          }
        end
        begin
          @files.each { |f| load f }
        rescue LoadError => e
          abort "Failed loading test file:\n#{e.message}"
        end
        case framework
        when :minitest5
          suites = Minitest::Runnable.runnables
        when :minitest_old
          suites = MiniTest::Unit::TestCase.test_suites
        when :testunit1, :testunit2
          suites = Test::Unit::TestCase.test_suites
        else
          not_supported
        end
        suites.inject({}) do |suites, suite_class|
          test_methods = case framework
          when :minitest5
            suite_class.runnable_methods
          else
            suite_class.test_methods
          end
          suites[suite_class] = test_methods if test_methods.size > 0
          suites
        end
      end
def suites $: . unshift "./test" , "./lib" if framework == :testunit1 Test :: Unit :: TestCase . class_eval { @@test_suites = { } def self . inherited ( klass ) @@test_suites [ klass ] = true end def self . test_suites @@test_suites . keys end def self . test_methods public_instance_methods ( true ) . grep ( / ^test / ) . map ( & :to_s ) end } end begin @files . each { | f | load f } rescue LoadError => e abort "Failed loading test file:\n#{e.message}" end case framework when :minitest5 suites = Minitest :: Runnable . runnables when :minitest_old suites = MiniTest :: Unit :: TestCase . test_suites when :testunit1 , :testunit2 suites = Test :: Unit :: TestCase . test_suites else not_supported end suites . inject ( { } ) do | suites , suite_class | test_methods = case framework when :minitest5 suite_class . runnable_methods else suite_class . test_methods end suites [ suite_class ] = test_methods if test_methods . size > 0 suites end end
Finds all test suites in this test file, with test methods included.
Finds all test suites in this test file with test methods included .
# Since we're not using `ruby -Itest -Ilib` to run the tests, we need to add this directory to the `LOAD_PATH` # Fire up the Ruby files. Let's hope they actually have tests. # Fail with a happier error message instead of spitting out a backtrace from this gem # Figure out what test framework we're using # Use some janky internal APIs to group test methods by test suite. # End up with a hash of suite class name to an array of test methods, so we can later find them and ignore empty test suites