Module: YardExampleTest::Example::Comparison

Included in:
YardExampleTest::Example
Defined in:
lib/yard_example_test/example/comparison.rb

Overview

Comparison and matcher logic for verifying example expectations

This module is included into YardExampleTest::Example so that its methods have direct access to Minitest assertions (+assert+, +assert_equal+, +assert_nil+, +diff+) inherited from +Minitest::Spec+. It also delegates to the Evaluator (via #evaluator) for expression evaluation.

The module handles three verification strategies:

  1. Block matchers — matchers that implement +supports_block_expectations?+ (e.g. RSpec's +raise_error+, +change+, +output+). The actual expression is wrapped in a +Proc+ and passed unevaluated.
  2. Value matchers — matchers that implement +matches?+ (e.g. +eq+, +be_a+, +be_within+). The actual expression is evaluated and the resulting value is passed.
  3. Bare values — compared via #compare_values using error handling, +nil+ checks, and +===+ case equality.