Class: Smartest::EndWithMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(*suffixes) ⇒ EndWithMatcher

Returns a new instance of EndWithMatcher.



107
108
109
# File 'lib/smartest/matchers.rb', line 107

def initialize(*suffixes)
  @suffixes = suffixes
end

Instance Method Details

#failure_messageObject



118
119
120
# File 'lib/smartest/matchers.rb', line 118

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
115
116
# File 'lib/smartest/matchers.rb', line 111

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

#negated_failure_messageObject



122
123
124
# File 'lib/smartest/matchers.rb', line 122

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