Module: Kettle::Dev::ExitAdapter

Defined in:
lib/kettle/dev/exit_adapter.rb,
sig/kettle/dev.rbs

Overview

Exit/abort indirection layer to allow controllable behavior in tests.

Production/default behavior delegates to Kernel.abort / Kernel.exit, which raise SystemExit. Specs can stub these methods to avoid terminating the process or to assert on arguments without coupling to Kernel.

Example (RSpec):

allow(Kettle::Dev::ExitAdapter).to receive(:abort).and_raise(SystemExit.new(1))

This adapter mirrors the "mockable adapter" approach used for GitAdapter.

Defined Under Namespace

Classes: AbortError

Class Method Summary collapse

Class Method Details

.abort(msg) ⇒ void

This method returns an undefined value.

Abort the current execution with a message. By default this calls Kernel.abort, which raises SystemExit after printing the message to STDERR.

Parameters:

  • msg (String)


27
28
29
# File 'lib/kettle/dev/exit_adapter.rb', line 27

def abort(msg)
  Kernel.abort(msg)
end

.abort_as_errorObject



39
40
41
42
43
# File 'lib/kettle/dev/exit_adapter.rb', line 39

def abort_as_error
  yield
rescue SystemExit => error
  raise AbortError, error.message
end

.exit(status = 0) ⇒ void

This method returns an undefined value.

Exit the current process with a given status code. By default this calls Kernel.exit.

Parameters:

  • status (Integer) (defaults to: 0)


35
36
37
# File 'lib/kettle/dev/exit_adapter.rb', line 35

def exit(status = 0)
  Kernel.exit(status)
end