Class: RSpec::SleepingKingStudios::Matchers::Core::BeBooleanMatcher

Inherits:
BaseMatcher
  • Object
show all
Includes:
Matchers::Composable
Defined in:
lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb

Overview

Matcher for testing whether an object is true or false.

Since:

  • 1.0.0

Constant Summary

Constants included from Description

Description::DEFAULT_EXPECTED_ITEMS

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual

Instance Method Summary collapse

Methods inherited from BaseMatcher

#does_not_match?

Instance Method Details

#descriptionObject

Since:

  • 1.0.0



14
15
16
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 14

def description
  'be true or false'
end

#failure_messageObject

Message for when the object does not match, but was expected to. Make sure to always call #matches? first to set up the matcher state.

Since:

  • 1.0.0



30
31
32
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 30

def failure_message
  "expected #{@actual.inspect} to be true or false"
end

#failure_message_when_negatedObject

Message for when the object matches, but was expected not to. Make sure to always call #matches? first to set up the matcher state.

Since:

  • 1.0.0



35
36
37
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 35

def failure_message_when_negated
  "expected #{@actual.inspect} not to be true or false"
end

#matches?(actual) ⇒ Boolean

Checks if the object is true or false.

Parameters:

  • actual (Object)

    The object to check.

Returns:

  • (Boolean)

    True if the object is true or false, otherwise false.

Since:

  • 1.0.0



23
24
25
26
27
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 23

def matches? actual
  super

  true === actual || false === actual
end