Class: Minicrest::Blank
Overview
Matcher that checks if a string is blank (empty or whitespace-only).
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 a blank string.
-
#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.
26 27 28 |
# File 'lib/minicrest/blank.rb', line 26 def description 'a blank string' end |
#failure_message(actual) ⇒ String
Returns the failure message when the match fails.
34 35 36 37 38 39 |
# File 'lib/minicrest/blank.rb', line 34 def (actual) <<~MSG.chomp expected #{actual.inspect} to be blank MSG end |
#matches?(actual) ⇒ Boolean
Checks if actual is a blank string.
15 16 17 18 19 20 21 |
# File 'lib/minicrest/blank.rb', line 15 def matches?(actual) return false unless actual.respond_to?(:strip) actual.strip.empty? rescue NoMethodError false end |
#negated_failure_message(actual) ⇒ String
Returns the failure message when a negated match fails.
45 46 47 48 49 50 51 |
# File 'lib/minicrest/blank.rb', line 45 def (actual) <<~MSG.chomp expected #{actual.inspect} not to be blank but it is MSG end |