Sha256: 36af92c7459074f44fe57d8fbd4a8dd081eda831e06ed4aeecddc145015f7c0e

Contents?: true

Size: 1000 Bytes

Versions: 4

Compression:

Stored size: 1000 Bytes

Contents

# frozen_string_literal: true

module SolargraphTestCoverage
  # Parent Class for different testing frameworks
  class TestRunner
    def self.with(test_file)
      case Config.test_framework
      when 'rspec'
        RSpecRunner.new(test_file)
      when 'minitest'
        MinitestRunner.new(test_file)
      end
    end

    def initialize(test_file)
      @test_file = test_file
      @result    = nil
    end

    def run!
      @result = test_framework_runner.run([@test_file])
      self
    end

    def passed?
      raise NotImplementedError
    end

    def test_framework_runner
      raise NotImplementedError
    end
  end

  # Test Runner Subclass for RSpec
  class RSpecRunner < TestRunner
    def passed?
      @result&.zero?
    end

    def test_framework_runner
      RSpec::Core::Runner
    end
  end

  # Test Runner Subclass for Minitest
  class MinitestRunner < TestRunner
    def passed?
      @result
    end

    def test_framework_runner
      Minitest
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solargraph_test_coverage-0.2.3 lib/solargraph_test_coverage/test_runner.rb
solargraph_test_coverage-0.2.2 lib/solargraph_test_coverage/test_runner.rb
solargraph_test_coverage-0.2.1 lib/solargraph_test_coverage/test_runner.rb
solargraph_test_coverage-0.2.0 lib/solargraph_test_coverage/test_runner.rb