Class: Smartest::EndWithMatcher

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

Instance Method Summary collapse

Methods inherited from Matcher

#and, #or

Constructor Details

#initialize(*suffixes) ⇒ EndWithMatcher

Returns a new instance of EndWithMatcher.



294
295
296
# File 'lib/smartest/matchers.rb', line 294

def initialize(*suffixes)
  @suffixes = suffixes
end

Instance Method Details

#descriptionObject



313
314
315
# File 'lib/smartest/matchers.rb', line 313

def description
  "end with #{expected_description}"
end

#failure_messageObject



305
306
307
# File 'lib/smartest/matchers.rb', line 305

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


298
299
300
301
302
303
# File 'lib/smartest/matchers.rb', line 298

def matches?(actual)
  @actual = actual
  actual.end_with?(*@suffixes)
rescue NoMethodError
  false
end

#negated_failure_messageObject



309
310
311
# File 'lib/smartest/matchers.rb', line 309

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