Class: Smartest::IncludeMatcher

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) ⇒ IncludeMatcher

Returns a new instance of IncludeMatcher.



236
237
238
# File 'lib/smartest/matchers.rb', line 236

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



255
256
257
# File 'lib/smartest/matchers.rb', line 255

def description
  "include #{@expected.inspect}"
end

#failure_messageObject



247
248
249
# File 'lib/smartest/matchers.rb', line 247

def failure_message
  "expected #{@actual.inspect} to include #{@expected.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


240
241
242
243
244
245
# File 'lib/smartest/matchers.rb', line 240

def matches?(actual)
  @actual = actual
  actual.include?(@expected)
rescue NoMethodError
  false
end

#negated_failure_messageObject



251
252
253
# File 'lib/smartest/matchers.rb', line 251

def negated_failure_message
  "expected #{@actual.inspect} not to include #{@expected.inspect}"
end