Class: Minicrest::IsLessThan

Inherits:
ComparisonMatcher show all
Defined in:
lib/minicrest/is_less_than.rb

Overview

Matcher that checks if a value is less than an expected value.

Works with any objects that support the < operator.

Examples:

Basic usage

is_less_than(5).matches?(3)    # => true
is_less_than(5).matches?(5)    # => false
is_less_than(5).matches?(10)   # => false

With floats

is_less_than(3.14).matches?(3.13)  # => true

Combined for range checking

in_range = is_greater_than(0) & is_less_than(10)
in_range.matches?(5)  # => true

See Also:

Instance Method Summary collapse

Methods inherited from ComparisonMatcher

#description, #failure_message, #matches?, #negated_failure_message

Methods inherited from Matcher

#&, #description, #failure_message, #matches?, #negated_failure_message, #|

Constructor Details

#initialize(expected) ⇒ IsLessThan

Creates a new less-than matcher.

Parameters:

  • expected (Comparable)

    the value to compare against



26
27
28
# File 'lib/minicrest/is_less_than.rb', line 26

def initialize(expected)
  super(expected, :<, 'less than')
end