Skip to content

Commit

Permalink
More exit code check specs
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Jan 9, 2021
1 parent d4ed992 commit 52cb560
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
8 changes: 2 additions & 6 deletions spec/exit_codes/minimum_coverage_by_file_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@
context "all files passing requirements" do
let(:minimum_coverage_by_file) { {line: 80} }

it "passes" do
expect(subject).not_to be_failing
end
it { is_expected.not_to be_failing }
end

context "one file violating requirements" do
let(:minimum_coverage_by_file) { {line: 90} }

it "fails" do
expect(subject).to be_failing
end
it { is_expected.to be_failing }
end
end
41 changes: 41 additions & 0 deletions spec/exit_codes/minimum_overall_coverage_check_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit 52cb560

Please sign in to comment.