Sha256: 4320ff0c05eec27eed61c763d22f6d79c35ba328c23957d21b1361b9c6c0d83b

Contents?: true

Size: 1.63 KB

Versions: 36

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require File.expand_path("../../test_helper", File.dirname(__FILE__))

if defined?(RubyVM::AbstractSyntaxTree)
  require "coverband/utils/dead_methods"
  module Coverband
    module Utils
      class DeadMethodsTest < Minitest::Test
        attr_accessor :coverband

        def setup
          super
          @coverband = Coverband::Collectors::Coverage.instance
        end

        def test_dog_dead_methods
          file_path = require_unique_file
          coverage = [nil, nil, 1, 1, 0, nil, nil]
          dead_methods =
            DeadMethods.scan(file_path: file_path, coverage: coverage)
          assert_equal(1, dead_methods.length)
          dead_method = dead_methods.first
          assert_equal(4, dead_method.first_line_number)
          assert_equal(6, dead_method.last_line_number)
          assert_equal(file_path, dead_method.file_path)
        end

        def test_all_dead_methods
          require_unique_file
          @coverband.report_coverage
          dead_methods = DeadMethods.scan_all
          dead_method = dead_methods.find { |method| method.class_name == :Dog }
          assert(dead_method)
          assert_equal(4, dead_method.first_line_number)
          assert_equal(6, dead_method.last_line_number)
        end

        def test_output_all
          require_unique_file
          @coverband.report_coverage
          DeadMethods.output_all
        end

        def test_dog_methods_not_dead
          file = require_unique_file
          coverage = [nil, nil, 1, 1, 1, nil, nil]
          assert_empty(DeadMethods.scan(file_path: file, coverage: coverage))
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
coverband-6.1.4 test/coverband/utils/dead_methods_test.rb
coverband-6.1.3 test/coverband/utils/dead_methods_test.rb
coverband-6.1.2 test/coverband/utils/dead_methods_test.rb
coverband-6.1.2.rc.1 test/coverband/utils/dead_methods_test.rb
coverband-6.1.1 test/coverband/utils/dead_methods_test.rb
coverband-6.1.0 test/coverband/utils/dead_methods_test.rb
coverband-6.0.3.rc.4 test/coverband/utils/dead_methods_test.rb
coverband-6.0.3.rc.3 test/coverband/utils/dead_methods_test.rb
coverband-6.0.3.rc.2 test/coverband/utils/dead_methods_test.rb
coverband-6.0.3.rc.1 test/coverband/utils/dead_methods_test.rb
coverband-6.0.2 test/coverband/utils/dead_methods_test.rb
coverband-6.0.1 test/coverband/utils/dead_methods_test.rb
coverband-6.0.1.rc.1 test/coverband/utils/dead_methods_test.rb
coverband-6.0.0 test/coverband/utils/dead_methods_test.rb
coverband-5.2.6.rc.6 test/coverband/utils/dead_methods_test.rb
coverband-5.2.3.2 test/coverband/utils/dead_methods_test.rb
coverband-5.2.6.rc.5 test/coverband/utils/dead_methods_test.rb
coverband-5.2.3.1 test/coverband/utils/dead_methods_test.rb
coverband-5.2.6.rc.4 test/coverband/utils/dead_methods_test.rb
coverband-5.2.6.rc.3 test/coverband/utils/dead_methods_test.rb