Class: Smartest::BeAKindOfMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/smartest/matchers.rb

Instance Method Summary collapse

Methods inherited from Matcher

#and, #or

Constructor Details

#initialize(expected_class) ⇒ BeAKindOfMatcher

Returns a new instance of BeAKindOfMatcher.



327
328
329
# File 'lib/smartest/matchers.rb', line 327

def initialize(expected_class)
  @expected_class = expected_class
end

Instance Method Details

#descriptionObject



346
347
348
# File 'lib/smartest/matchers.rb', line 346

def description
  "be a kind of #{expected_description}"
end

#failure_messageObject



338
339
340
# File 'lib/smartest/matchers.rb', line 338

def failure_message
  "expected #{@actual.inspect} to be a kind of #{expected_description}, but was #{actual_class_description}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


331
332
333
334
335
336
# File 'lib/smartest/matchers.rb', line 331

def matches?(actual)
  @actual = actual
  actual.is_a?(@expected_class)
rescue TypeError
  false
end

#negated_failure_messageObject



342
343
344
# File 'lib/smartest/matchers.rb', line 342

def negated_failure_message
  "expected #{@actual.inspect} not to be a kind of #{expected_description}, but was #{actual_class_description}"
end