Sha256: dc16f5abad39b2ed30d6efc9cf7968021074985802ee6293fde6d73696511a3e

Contents?: true

Size: 1.91 KB

Versions: 20

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

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

describe 'results' do
  describe 'with a (mocked) Coverage.result' do
    let(:source_file) { Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), run_lines) }
    let(:eager_lines) { [nil, 1, 1, 0, nil, nil, 1, 0, nil, nil] }
    let(:run_lines) { [nil, nil, nil, 1, nil, nil, nil,nil, nil, nil] }
    let(:original_result) do
      orig = {
        Coverband::MERGED_TYPE => {source_fixture('app/models/user.rb') => eager_lines},
      }
      orig.merge!({Coverband::EAGER_TYPE => {source_fixture('app/models/user.rb') => eager_lines}}) if eager_lines
      orig.merge!({Coverband::RUNTIME_TYPE => {source_fixture('app/models/user.rb') => run_lines}}) if run_lines
      orig
    end
    subject { Coverband::Utils::Results.new(original_result) }

    describe 'runtime relevant lines is supported' do
      it 'has correct runtime relevant coverage' do
        assert_equal 50.0, subject.runtime_relevant_coverage(source_file)
      end

      it 'has correct runtime relevant lines' do
        assert_equal 2, subject.runtime_relavent_lines(source_file)
      end
    end

    describe 'runtime relevant lines when no runtime coverage exists' do
      let(:run_lines) { nil }

      it 'has correct runtime relevant lines' do
        assert_equal 0.0, subject.runtime_relevant_coverage(source_file)
      end

      it 'has correct runtime relevant lines' do
        assert_equal 2, subject.runtime_relavent_lines(source_file)
      end
    end

    describe 'runtime relevant lines when no eager coverage exists' do
      let(:eager_lines) { nil }

      it 'has correct runtime relevant lines' do
        assert_equal 100.0, subject.runtime_relevant_coverage(source_file)
      end

      it 'has correct runtime relevant lines' do
        assert_equal 1, subject.runtime_relavent_lines(source_file)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
coverband-4.2.7 test/coverband/utils/results_test.rb
coverband-4.2.7.rc.1 test/coverband/utils/results_test.rb
coverband-4.2.6 test/coverband/utils/results_test.rb
coverband-4.2.5 test/coverband/utils/results_test.rb
coverband-4.2.5.rc.2 test/coverband/utils/results_test.rb
coverband-4.2.5.rc.1 test/coverband/utils/results_test.rb
coverband-4.2.4 test/coverband/utils/results_test.rb
coverband-4.2.4.rc.3 test/coverband/utils/results_test.rb
coverband-4.2.4.rc.2 test/coverband/utils/results_test.rb
coverband-4.2.4.rc.1 test/coverband/utils/results_test.rb
coverband-4.2.3 test/coverband/utils/results_test.rb
coverband-4.2.3.rc.2 test/coverband/utils/results_test.rb
coverband-4.2.3.rc.1 test/coverband/utils/results_test.rb
coverband-4.2.2 test/coverband/utils/results_test.rb
coverband-4.2.2.rc.1 test/coverband/utils/results_test.rb
coverband-4.2.1 test/coverband/utils/results_test.rb
coverband-4.2.1.rc4 test/coverband/utils/results_test.rb
coverband-4.2.1.rc3 test/coverband/utils/results_test.rb
coverband-4.2.1.rc2 test/coverband/utils/results_test.rb
coverband-4.2.1.rc1 test/coverband/utils/results_test.rb