Files
openfoodnetwork/spec/lib/tasks/simplecov_spec.rb
Maikel Linke 2555a9e710 Ignore breaking code coverage for coverage spec
When we test our code coverage compilation, it breaks the code coverage
report for the current rspec process. By running that code separately,
we gain a correct coverage report for the rest of the code again.

So unfortunately, we can't report on the code coverage of this
particular task and have to ignore it. But at least CI depends on the
correct function of this task and would fail if it didn't work.
2025-08-05 12:45:05 +10:00

42 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "simplecov.rake" do
include_context "rake"
describe "simplecov:collate_results" do
context "when there are reports to merge" do
let(:input_dir) { Rails.root.join("spec/fixtures/simplecov") }
it "creates a new combined report" do
Dir.mktmpdir do |tmp_dir|
output_dir = File.join(tmp_dir, "output")
task_name = "simplecov:collate_results[#{input_dir},#{output_dir}]"
expect {
if ENV["COVERAGE"]
# Start task in a new process to not mess with our coverage report.
`bundle exec rake #{task_name}`
else
# Use the quick standard invocation in dev.
invoke_task(task_name)
end
}.to change { Dir.exist?(output_dir) }.
from(false).
to(true).
and change { File.exist?(File.join(output_dir, "index.html")) }.
from(false).
to(true).
and change { File.exist?(File.join(output_dir, "coverage.json")) }.
from(false).
to(true)
end
end
end
end
end