Class: Minicrest::Empty
Overview
Matcher that checks if a value is empty.
Works with any object that responds to empty?: - Strings - Arrays - Hashes - Sets - Any Enumerable
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
Checks if actual is empty.
-
#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.
31 32 33 |
# File 'lib/minicrest/empty.rb', line 31 def description 'empty' end |
#failure_message(actual) ⇒ String
Returns the failure message when the match fails.
39 40 41 42 43 |
# File 'lib/minicrest/empty.rb', line 39 def (actual) <<~MSG.chomp expected #{actual.inspect} to be empty, but had size #{actual.size} MSG end |
#matches?(actual) ⇒ Boolean
Checks if actual is empty.
24 25 26 |
# File 'lib/minicrest/empty.rb', line 24 def matches?(actual) actual.empty? end |
#negated_failure_message(actual) ⇒ String
Returns the failure message when a negated match fails.
49 50 51 52 53 |
# File 'lib/minicrest/empty.rb', line 49 def (actual) <<~MSG.chomp expected #{actual.inspect} not to be empty, but it was MSG end |