Module: Kettle::Dev::ExitAdapter
- Defined in:
- lib/kettle/dev/exit_adapter.rb
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.
Class Method Summary collapse
-
.abort(msg) ⇒ void
Abort the current execution with a message.
-
.exit(status = 0) ⇒ void
Exit the current process with a given status code.
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.
23 24 25 |
# File 'lib/kettle/dev/exit_adapter.rb', line 23 def abort(msg) Kernel.abort(msg) 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.
31 32 33 |
# File 'lib/kettle/dev/exit_adapter.rb', line 31 def exit(status = 0) Kernel.exit(status) end |