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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
# frozen_string_literal: true
require "helper"
describe SimpleCov::Result do
subject do
original_result = {
source_fixture("sample.rb") => {
"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
"branches" => {}
},
source_fixture("app/models/user.rb") => {
"lines" => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
"branches" => {}
},
source_fixture("app/controllers/sample_controller.rb") => {
"lines" => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil],
"branches" => {}
}
}
SimpleCov::Result.new(original_result).files
end
it "has 11 covered lines" do
expect(subject.covered_lines).to eq(11)
end
it "has 3 missed lines" do
expect(subject.missed_lines).to eq(3)
end
it "has 17 never lines" do
expect(subject.never_lines).to eq(17)
end
it "has 14 lines of code" do
expect(subject.lines_of_code).to eq(14)
end
it "has 5 skipped lines" do
expect(subject.skipped_lines).to eq(5)
end
it "has the correct covered percent" do
expect(subject.covered_percent).to eq(78.57142857142857)
end
it "has the correct covered percentages" do
expect(subject.covered_percentages).to eq([50.0, 80.0, 100.0])
end
it "has the correct least covered file" do
expect(subject.least_covered_file).to match(/sample_controller.rb/)
end
it "has the correct covered strength" do
expect(subject.covered_strength).to eq(0.9285714285714286)
end
end
|