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.



139
140
141
# File 'lib/smartest/matchers.rb', line 139

def initialize(*suffixes)
  @suffixes = suffixes
end

Instance Method Details

#descriptionObject



158
159
160
# File 'lib/smartest/matchers.rb', line 158

def description
  "end with #{expected_description}"
end

#failure_messageObject



150
151
152
# File 'lib/smartest/matchers.rb', line 150

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


143
144
145
146
147
148
# File 'lib/smartest/matchers.rb', line 143

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

#negated_failure_messageObject



154
155
156
# File 'lib/smartest/matchers.rb', line 154

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