Class: Fix::Run Private

Inherits:
Object
  • Object
show all
Defined in:
lib/fix/run.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.

Executes a test specification by running a subject against a set of challenges and requirements.

The Run class orchestrates test execution by:

  1. Evaluating the test subject in the proper environment

  2. Applying a series of method challenges to the result

  3. Verifying the final value against the requirement

Examples:

Running a simple test

run = Run.new(env, requirement)
run.test { MyClass.new }

Running with method challenges

run = Run.new(env, requirement, challenge1, challenge2)
run.test { MyClass.new }  # Will call methods defined in challenges

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, requirement, *challenges) ⇒ Run

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.

Initializes a new test run with the given environment and challenges.

Examples:

Run.new(test_env, must_be_positive, increment_method)

Parameters:

  • environment (::Fix::Dsl)

    Context instance with test setup

  • requirement (::Spectus::Requirement::Base)

    Expectation to verify

  • challenges (Array<::Defi::Method>)

    Method calls to apply



44
45
46
47
48
# File 'lib/fix/run.rb', line 44

def initialize(environment, requirement, *challenges)
  @environment = environment
  @requirement = requirement
  @challenges = challenges
end

Instance Attribute Details

#challengesArray<::Defi::Method> (readonly)

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.

The list of method calls to apply to the subject

Returns:

  • (Array<::Defi::Method>)

    A list of challenges



34
35
36
# File 'lib/fix/run.rb', line 34

def challenges
  @challenges
end

#environment::Fix::Dsl (readonly)

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.

The test environment containing defined variables and methods

Returns:



26
27
28
# File 'lib/fix/run.rb', line 26

def environment
  @environment
end

#requirement::Spectus::Requirement::Base (readonly)

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.

The specification requirement to validate against

Returns:

  • (::Spectus::Requirement::Base)

    An expectation



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

def requirement
  @requirement
end

Instance Method Details

#test(&subject) ⇒ ::Expresenter::Pass

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.

Verifies if the subject meets the requirement after applying all challenges.

Examples:

Basic testing

run.test { 42 }

Testing with subject modification

run.test { User.new(name: "John") }

Parameters:

  • subject (Proc)

    The block of code to be tested

Returns:

  • (::Expresenter::Pass)

    When the test specification passes

Raises:

  • (::Expresenter::Fail)

    When the test specification fails

See Also:



64
65
66
67
68
# File 'lib/fix/run.rb', line 64

def test(&subject)
  requirement.call { actual_value(&subject) }
rescue ::Expresenter::Fail => e
  e
end