Class: Minicrest::Anything
Overview
Matcher that matches any value (placeholder matcher).
Use this when you want to assert the structure of data but don’t care about specific values, or when testing that something exists without caring what it is.
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.
-
#matches?(_actual) ⇒ Boolean
Matches any value.
-
#negated_failure_message(actual) ⇒ String
Returns the failure message when a negated match fails.
Methods inherited from Matcher
Instance Method Details
#description ⇒ String
Returns a description of what this matcher expects.
30 31 32 |
# File 'lib/minicrest/anything.rb', line 30 def description 'anything' end |
#failure_message(actual) ⇒ String
Returns the failure message when the match fails.
Note: This method should never be called since anything always matches.
40 41 42 43 44 |
# File 'lib/minicrest/anything.rb', line 40 def (actual) <<~MSG.chomp expected #{actual.inspect} to be anything (this should never fail) MSG end |
#matches?(_actual) ⇒ Boolean
Matches any value.
23 24 25 |
# File 'lib/minicrest/anything.rb', line 23 def matches?(_actual) true end |
#negated_failure_message(actual) ⇒ String
Returns the failure message when a negated match fails.
This is called when does_not(anything) fails because anything matched.
52 53 54 55 56 |
# File 'lib/minicrest/anything.rb', line 52 def (actual) <<~MSG.chomp expected #{actual.inspect} not to be anything, but everything is something MSG end |