Class: Smartest::BeAKindOfMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_class) ⇒ BeAKindOfMatcher

Returns a new instance of BeAKindOfMatcher.



172
173
174
# File 'lib/smartest/matchers.rb', line 172

def initialize(expected_class)
  @expected_class = expected_class
end

Instance Method Details

#descriptionObject



191
192
193
# File 'lib/smartest/matchers.rb', line 191

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

#failure_messageObject



183
184
185
# File 'lib/smartest/matchers.rb', line 183

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
179
180
181
# File 'lib/smartest/matchers.rb', line 176

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

#negated_failure_messageObject



187
188
189
# File 'lib/smartest/matchers.rb', line 187

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