Class: TestTube::Invoker Private

Inherits:
Experiment show all
Defined in:
lib/test_tube/invoker.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Evaluate an actual value invoking it with #call method. This class is designed to handle ALL possible exceptions during test execution, including system-level exceptions. This is crucial for testing frameworks to:

  • Capture system exceptions (SystemExit, SignalException, etc.)

  • Prevent test suite interruption through exit calls

  • Ensure complete control over the test execution flow

  • Allow proper reporting of all types of failures

Examples:

Handling a system exit

TestTube.invoke(matcher: SomeExitMatcher.new, negate: false) do
  exit(true)  # Will be caught and handled properly
end

Instance Attribute Summary

Attributes inherited from Experiment

#actual, #error, #got

Instance Method Summary collapse

Methods inherited from Experiment

#inspect

Constructor Details

#initialize(matcher:, negate:, &input) ⇒ Invoker

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Class initializer.

Parameters:

  • matcher (#match?)

    The matcher to evaluate the result

  • negate (Boolean)

    Whether to invert the matcher result

  • input (Proc)

    The callable object to test

Raises:

  • (ArgumentError)

    If the matcher doesn’t respond to match?



29
30
31
32
33
34
# File 'lib/test_tube/invoker.rb', line 29

def initialize(matcher:, negate:, &input)
  validate_matcher(matcher)
  validate_negate(negate)
  super()
  perform_experiment(matcher, negate, input)
end