diff --git a/fixtures/autostart/report.rb b/fixtures/autostart/report.rb new file mode 100644 index 0000000..7952ee2 --- /dev/null +++ b/fixtures/autostart/report.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +# Released under the MIT License. +# Copyright, 2026, by Samuel Williams. + +puts "autostart fixture" diff --git a/fixtures/sus/dummy.rb b/fixtures/sus/dummy.rb new file mode 100644 index 0000000..507fda1 --- /dev/null +++ b/fixtures/sus/dummy.rb @@ -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 diff --git a/test/covered/autostart.rb b/test/covered/autostart.rb index efefc2c..758a63b 100644 --- a/test/covered/autostart.rb +++ b/test/covered/autostart.rb @@ -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 diff --git a/test/covered/minitest.rb b/test/covered/minitest.rb index 87cf97b..1eeab88 100644 --- a/test/covered/minitest.rb +++ b/test/covered/minitest.rb @@ -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 diff --git a/test/covered/rspec.rb b/test/covered/rspec.rb index a607f56..f9ef918 100644 --- a/test/covered/rspec.rb +++ b/test/covered/rspec.rb @@ -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 diff --git a/test/covered/sus.rb b/test/covered/sus.rb index b897fc9..bba56d6 100644 --- a/test/covered/sus.rb +++ b/test/covered/sus.rb @@ -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 @@ -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