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

Inherits:
BaseMatcher
  • Object
show all
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



12
13
14
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 12

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



28
29
30
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 28

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



33
34
35
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean_matcher.rb', line 33

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



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

def matches? actual
  super

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