Module: Kettle::Test

Defined in:
lib/kettle/test.rb,
lib/kettle/test/version.rb

Overview

Test support and RSpec integration for kettle-rb ecosystem.

Exposes environment-controlled constants and helpers that tune RSpec behavior
(profiling, backtraces, output silencing, CI filters) and provides a minimal
API for detecting parallel test execution.

See README for configuration and usage examples.

Defined Under Namespace

Modules: Version Classes: Error

Constant Summary collapse

DEBUG =

String#casecmp? was added in Ruby 2.4, so fallback to String#casecmp

Returns:

  • (Boolean)

    whether debug mode is enabled (disables silencing)

ENV.fetch("KETTLE_TEST_DEBUG", ENV.fetch("DEBUG", "false")).casecmp("true").zero?
IS_CI =

Returns whether running in a CI environment (CI=true).

Returns:

  • (Boolean)

    whether running in a CI environment (CI=true)

ENV.fetch("CI", "").casecmp("true").zero?
FULL_BACKTRACE =

Returns when true, enables full backtraces in RSpec.

Returns:

  • (Boolean)

    when true, enables full backtraces in RSpec

ENV.fetch("KETTLE_TEST_FULL_BACKTRACE", "false").casecmp("true").zero?
RSPEC_PROFILE_EXAMPLES_NUM =

Returns number of examples to profile (0 disables profiling).

Returns:

  • (Integer)

    number of examples to profile (0 disables profiling)

ENV.fetch("KETTLE_TEST_RSPEC_PROFILE_EXAMPLES", "0").to_i
RSPEC_PROFILE_EXAMPLES =

Returns whether profiling is enabled.

Returns:

  • (Boolean)

    whether profiling is enabled

RSPEC_PROFILE_EXAMPLES_NUM > 0
RSPEC_VERSION =

If RSpec’s version is < 3, enable transpec to facilitate the upgrade.

Returns:

  • (Gem::Version)

    active RSpec version

::Gem::Version.new(RSpec::Core::Version::STRING)
SILENT =

Returns when true, STDOUT/STDERR are silenced during specs (unless :check_output or DEBUG).

Returns:

  • (Boolean)

    when true, STDOUT/STDERR are silenced during specs (unless :check_output or DEBUG)

ENV.fetch("KETTLE_TEST_SILENT", IS_CI.to_s).casecmp("true").zero?
TRANSPEC =

Returns whether transpec compatibility mode should be enabled.

Returns:

  • (Boolean)

    whether transpec compatibility mode should be enabled

::Gem::Version.new("3.0") > RSPEC_VERSION
TREAT_AS_PARALLEL =

Returns whether the environment signals a parallel test run.

Returns:

  • (Boolean)

    whether the environment signals a parallel test run

ENV.fetch("PARALLEL_TEST_FIRST_IS_1", "").casecmp("true").zero?
VERBOSE =

Returns reserved for verbose logging toggles.

Returns:

  • (Boolean)

    reserved for verbose logging toggles

ENV.fetch("KETTLE_TEST_VERBOSE", "false").casecmp("true").zero?
GLOBAL_DATE =

time starts at midnight on GLOBAL_DATE

Returns:

  • (String)

    global travel time or date used as a baseline for timecop

ENV.fetch("GLOBAL_TIME_TRAVEL_TIME", ENV.fetch("GLOBAL_TIME_TRAVEL_DATE", Date.today.to_s))
TIME_MACHINE_SEQUENTIAL =

Returns when true, use sequential time machine mode for timecop-rspec.

Returns:

  • (Boolean)

    when true, use sequential time machine mode for timecop-rspec

ENV.fetch("KETTLE_TEST_TM_SEQUENTIAL", "true").casecmp("true").zero?

Class Method Summary collapse

Class Method Details

.is_parallel_test?Boolean

Detects whether tests are running in parallel.

Many parallel test runners set PARALLEL_TEST_FIRST_IS_1=true and provide
TEST_ENV_NUMBER for each worker. This helper checks those signals.

Returns:

  • (Boolean)


51
52
53
# File 'lib/kettle/test.rb', line 51

def is_parallel_test?
  TREAT_AS_PARALLEL && !ENV.fetch("TEST_ENV_NUMBER", "").empty?
end