module Output

Represents output handlers for test results and messages.

Nested Classes and Modules

class Backtrace

Represents a backtrace for displaying error locations.

class Bar

Represents a progress bar for displaying test execution progress.

class Buffered

Represents a buffered output handler that stores output operations for later replay.

class Lines

Represents a line buffer for managing multiple lines of output on a terminal.

module Messages

Provides message formatting methods for output handlers.

class Null

Represents a null output handler that discards all output.

class Progress

Represents a progress tracker for test execution.

class Status

Represents a status indicator for test execution.

class Structured

Represents a structured JSON output handler for machine-readable output.

class Text

Represents a plain text output handler without color support.

module Variable

Provides a compact, truncated representation of values for output.

class XTerm

Represents an XTerm-compatible output handler with color and style support.

Definitions

def self.github_actions?(env)

Detect if we're running in GitHub Actions, where human-readable output is preferred. GitHub Actions sets the GITHUB_ACTIONS environment variable to "true".

Signature

parameter env Hash

The environment variables to check.

Implementation

def self.github_actions?(env)
	env["GITHUB_ACTIONS"] == "true"
end

def self.for(io, env = ENV)

Create an appropriate output handler for the given IO.

Signature

parameter io IO

The IO object to write to.

parameter env Hash

The environment variables to consider (defaults to ENV).

returns XTerm, Text

An XTerm handler if the IO is a TTY or running in GitHub Actions, otherwise a Text handler.

Implementation

def self.for(io, env = ENV)
	if io.isatty or self.github_actions?(env)
		XTerm.new(io)
	else
		Text.new(io)
	end
end

def self.default(io = $stderr, env = ENV)

Create a default output handler with styling configured.

Signature

parameter io IO

The IO object to write to (defaults to $stderr).

parameter env Hash

The environment variables to consider (defaults to ENV).

returns XTerm, Text

A configured output handler.

Implementation

def self.default(io = $stderr, env = ENV)
	output = self.for(io, env)
	
	Output::Bar.register(output)
	
	output[:context] = output.style(nil, nil, :bold)
	
	output[:describe] = output.style(:cyan)
	output[:it] = output.style(:cyan)
	output[:with] = output.style(:cyan)
	
	output[:variable] = output.style(:blue, nil, :bold)
	
	# The ellipsis marks where an inspected value was truncated; it is shown
	# faintly so it reads as "trailing off" without competing with the value.
	output[:ellipsis] = output.style(nil, nil, :faint)
	
	output[:path] = output.style(:yellow)
	output[:line] = output.style(:yellow)
	output[:identity] = output.style(:yellow)
	
	output[:passed] = output.style(:green)
	output[:failed] = output.style(:red)
	output[:deferred] = output.style(:yellow)
	output[:skipped] = output.style(:blue)
	output[:errored] = output.style(:red)
	# output[:inform] = output.style(nil, nil, :bold)
	
	return output
end

def self.buffered

Create a buffered output handler.

Signature

returns Buffered

A new buffered output handler.

Implementation

def self.buffered
	Buffered.new
end