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(input, isolation:, matcher:, negate:) ⇒ Invoker

Returns A software experiment.

Examples:

require "test_tube"

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

TestTube.invoke(
  -> { "101010".to_i(2) },
  isolation: false,
  matcher:   BeTheAnswer.new,
  negate:    false
)

Parameters:

  • input (#call)

    The callable object to test.

  • isolation (Boolean)

    Compute in isolation or not.

  • matcher (#matches?)

    A matcher.

  • negate (Boolean)

    Invert the matcher or not.

Returns:

  • (Invoker)

    A software experiment.


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

def self.invoke(input, isolation:, matcher:, negate:)
  Invoker.new(input, isolation: isolation, matcher: matcher, negate: negate)
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 callable object to test.

  • matcher (#matches?)

    A matcher.

  • negate (Boolean)

    Invert the matcher or not.

Returns:

  • (Passer)

    A software experiment.


54
55
56
# File 'lib/test_tube.rb', line 54

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