Class: Minicrest::IsLessThanOrEqualTo
- Defined in:
- lib/minicrest/is_less_than_or_equal_to.rb
Overview
Matcher that checks if a value is less than or equal to an expected value.
Works with any objects that support the <= operator.
Instance Method Summary collapse
-
#description ⇒ String
Returns a description of what this matcher expects.
-
#failure_message(actual) ⇒ String
Returns the failure message when the match fails.
-
#initialize(expected) ⇒ IsLessThanOrEqualTo
constructor
Creates a new less-than-or-equal-to matcher.
-
#matches?(actual) ⇒ Boolean
Checks if actual is less than or equal to expected.
-
#negated_failure_message(actual) ⇒ String
Returns the failure message when a negated match fails.
Methods inherited from Matcher
Constructor Details
#initialize(expected) ⇒ IsLessThanOrEqualTo
Creates a new less-than-or-equal-to matcher.
16 17 18 19 |
# File 'lib/minicrest/is_less_than_or_equal_to.rb', line 16 def initialize(expected) super() @expected = expected end |
Instance Method Details
#description ⇒ String
Returns a description of what this matcher expects.
32 33 34 |
# File 'lib/minicrest/is_less_than_or_equal_to.rb', line 32 def description "less than or equal to #{@expected.inspect}" end |
#failure_message(actual) ⇒ String
Returns the failure message when the match fails.
40 41 42 43 44 |
# File 'lib/minicrest/is_less_than_or_equal_to.rb', line 40 def (actual) <<~MSG.chomp expected #{actual.inspect} to be less than or equal to #{@expected.inspect} MSG end |
#matches?(actual) ⇒ Boolean
Checks if actual is less than or equal to expected.
25 26 27 |
# File 'lib/minicrest/is_less_than_or_equal_to.rb', line 25 def matches?(actual) actual <= @expected end |
#negated_failure_message(actual) ⇒ String
Returns the failure message when a negated match fails.
50 51 52 53 54 |
# File 'lib/minicrest/is_less_than_or_equal_to.rb', line 50 def (actual) <<~MSG.chomp expected #{actual.inspect} not to be less than or equal to #{@expected.inspect}, but it was MSG end |