Sha256: 15013eae2e4e120ab8ab9f9abc81dc528d7c559659d2c8ffc602ee0fb34458ba

Contents?: true

Size: 699 Bytes

Versions: 6

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

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

module Covered
	module Sus
		def initialize(...)
			super
			
			# Defer loading the coverage configuration unless we are actually running with coverage enabled to avoid performance cost/overhead.
			if ENV['COVERAGE']
				require_relative 'config'
				
				@covered = Covered::Config.load(root: self.root)
				if @covered.record?
					@covered.enable
				end
			else
				@covered = nil
			end
		end
		
		def after_tests(assertions)
			super(assertions)
			
			if @covered&.record?
				@covered.disable
				@covered.call(self.output.io)
			end
		end
		
		def covered
			@covered
		end
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
covered-0.19.1 lib/covered/sus.rb
covered-0.19.0 lib/covered/sus.rb
covered-0.18.5 lib/covered/sus.rb
covered-0.18.4 lib/covered/sus.rb
covered-0.18.3 lib/covered/sus.rb
covered-0.18.2 lib/covered/sus.rb