Module: TestTube

Defined in:
lib/test_tube.rb,
lib/test_tube/base.rb,
lib/test_tube/passer.rb,
lib/test_tube/invoker.rb

Overview

Namespace for the TestTube library.

Defined Under Namespace

Classes: Base, Invoker, Passer

Class Method Summary collapse

Class Method Details

.invoke(isolate:, matcher:, negate:, &input) ⇒ Invoker

Returns A software experiment.

Examples:

require "test_tube"

class BeTheAnswer
  def matches?
    42.equal?(yield)
  end
end

TestTube.invoke(isolate: false, matcher: BeTheAnswer.new, negate: false) do
  "101010".to_i(2)
end

Parameters:

  • isolate (Boolean)

    Compute in a subprocess.

  • matcher (#matches?)

    A matcher.

  • negate (Boolean)

    Invert the matcher or not.

  • input (Proc)

    The callable object to test.

Returns:

  • (Invoker)

    A software experiment.


29
30
31
# File 'lib/test_tube.rb', line 29

def self.invoke(isolate:, matcher:, negate:, &input)
  Invoker.new(isolate: isolate, matcher: matcher, negate: negate, &input)
end

.pass(input, matcher:, negate:) ⇒ Passer

Returns A software experiment.

Examples:

require "test_tube"

class BeTheAnswer
  def matches?
    42.equal?(yield)
  end
end

TestTube.pass("101010".to_i(2),
  matcher: BeTheAnswer.new,
  negate: false
)

Parameters:

  • input (#object_id)

    The actual value to test.

  • matcher (#matches?)

    A matcher.

  • negate (Boolean)

    Invert the matcher or not.

Returns:

  • (Passer)

    A software experiment.


52
53
54
# File 'lib/test_tube.rb', line 52

def self.pass(input, matcher:, negate:)
  Passer.new(input, matcher: matcher, negate: negate)
end