Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions fixtures/autostart/report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.

puts "autostart fixture"
10 changes: 10 additions & 0 deletions fixtures/sus/dummy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.

describe "Hello World Sus Test" do
it "can hello world" do
expect("Hello World").to be == "Hello World"
end
end
14 changes: 14 additions & 0 deletions test/covered/autostart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.

require "covered"
require "covered/config"

describe "Coverage::Autostart" do
let(:script_path) {File.expand_path("../../fixtures/autostart/report.rb", __dir__)}

it "reports at exit when reports are enabled" do
input, output = IO.pipe

system({"COVERAGE" => "PartialSummary"}, "ruby", "-rcovered/autostart", script_path, out: output, err: output)
output.close

buffer = input.read
expect(buffer).to be(:include?, "autostart fixture")
expect(buffer).to be =~ /(.*?) files checked; (.*?) lines executed; (.*?)% covered/
end

it "starts coverage and reports at exit" do
events = []
exit_hook = nil

Expand Down
1 change: 1 addition & 0 deletions test/covered/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

buffer = input.read
expect(buffer).to be =~ /(.*?) files checked; (.*?) lines executed; (.*?)% covered/
expect(buffer).to be(:include?, "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips")
end

it "starts coverage before running minitest" do
Expand Down
1 change: 1 addition & 0 deletions test/covered/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

buffer = input.read
expect(buffer).to be =~ /(.*?) files checked; (.*?) lines executed; (.*?)% covered/
expect(buffer).to be(:include?, "1 example, 0 failures")
end

it "starts coverage before loading spec files" do
Expand Down
14 changes: 14 additions & 0 deletions test/covered/sus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.

require "covered"
require "covered/sus"

describe Covered::Sus do
let(:test_path) {File.expand_path("../../fixtures/sus/dummy.rb", __dir__)}

let(:coverage) do
Class.new do
attr :events
Expand Down Expand Up @@ -68,6 +71,17 @@ def after_tests(assertions)
end
end

it "can run sus test suite with coverage" do
input, output = IO.pipe

system({"COVERAGE" => "PartialSummary"}, "sus", test_path, out: output, err: output)
output.close

buffer = input.read
expect(buffer).to be =~ /(.*?) files checked; (.*?) lines executed; (.*?)% covered/
expect(buffer).to be(:include?, "1 passed out of 1 total")
end

it "starts and finishes configured coverage" do
config = coverage.new

Expand Down
Loading