File: minimum_overall_coverage_check_spec.rb

package info (click to toggle)
ruby-simplecov 0.22.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,512 kB
  • sloc: ruby: 5,550; makefile: 10
file content (41 lines) | stat: -rw-r--r-- 974 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

require "helper"

RSpec.describe SimpleCov::ExitCodes::MinimumOverallCoverageCheck do
  let(:result) do
    instance_double(SimpleCov::Result, coverage_statistics: stats)
  end
  let(:stats) do
    {
      line: SimpleCov::CoverageStatistics.new(covered: 8, missed: 2),
      branch: SimpleCov::CoverageStatistics.new(covered: 8, missed: 2)
    }
  end

  subject { described_class.new(result, minimum_coverage) }

  context "everything exactly ok" do
    let(:minimum_coverage) { {line: 80.0} }

    it { is_expected.not_to be_failing }
  end

  context "coverage violated" do
    let(:minimum_coverage) { {line: 90.0} }

    it { is_expected.to be_failing }
  end

  context "coverage slightly violated" do
    let(:minimum_coverage) { {line: 80.01} }

    it { is_expected.to be_failing }
  end

  context "one criterion violated" do
    let(:minimum_coverage) { {line: 80.0, branch: 90.0} }

    it { is_expected.to be_failing }
  end
end