Class: Minicrest::Truthy

Inherits:
Matcher show all
Defined in:
lib/minicrest/value_matchers.rb

Overview

Matcher that checks Ruby truthiness.

Instance Method Summary collapse

Methods inherited from Matcher

#&, #|

Instance Method Details

#descriptionObject



31
32
33
# File 'lib/minicrest/value_matchers.rb', line 31

def description
  'truthy'
end

#failure_message(actual) ⇒ Object



35
36
37
# File 'lib/minicrest/value_matchers.rb', line 35

def failure_message(actual)
  "expected #{actual.inspect} to be truthy"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/minicrest/value_matchers.rb', line 27

def matches?(actual)
  !!actual
end

#negated_failure_message(actual) ⇒ Object



39
40
41
# File 'lib/minicrest/value_matchers.rb', line 39

def negated_failure_message(actual)
  "expected #{actual.inspect} not to be truthy, but it was"
end