Class: RSpec::SleepingKingStudios::Matchers::BuiltIn::BeAKindOfMatcher

Inherits:
Matchers::BuiltIn::BeAKindOf
  • Object
show all
Defined in:
lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of_matcher.rb

Overview

Extensions to the built-in RSpec #be_kind_of matcher.

Instance Method Summary collapse

Instance Method Details

#descriptionObject



10
11
12
# File 'lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of_matcher.rb', line 10

def description
  message = "be #{type_string}"
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.



29
30
31
# File 'lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of_matcher.rb', line 29

def failure_message
  "expected #{@actual.inspect} to be #{type_string}"
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.



34
35
36
# File 'lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of_matcher.rb', line 34

def failure_message_when_negated
  "expected #{@actual.inspect} not to be #{type_string}"
end

#match(expected, actual) ⇒ Boolean

Checks if the object matches one of the specified types. Allows an expected value of nil as a shortcut for expecting an instance of NilClass.

Parameters:

  • expected (Module, nil, Array<Module, nil>)

    The type or types to check the object against.

  • actual (Object)

    The object to check.

Returns:

  • (Boolean)

    True if the object matches one of the specified types, otherwise false.



24
25
26
# File 'lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of_matcher.rb', line 24

def match expected, actual
  match_type? expected
end