Class: Smartest::StartWithMatcher

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

Instance Method Summary collapse

Methods inherited from Matcher

#and, #or

Constructor Details

#initialize(*prefixes) ⇒ StartWithMatcher

Returns a new instance of StartWithMatcher.



261
262
263
# File 'lib/smartest/matchers.rb', line 261

def initialize(*prefixes)
  @prefixes = prefixes
end

Instance Method Details

#descriptionObject



280
281
282
# File 'lib/smartest/matchers.rb', line 280

def description
  "start with #{expected_description}"
end

#failure_messageObject



272
273
274
# File 'lib/smartest/matchers.rb', line 272

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


265
266
267
268
269
270
# File 'lib/smartest/matchers.rb', line 265

def matches?(actual)
  @actual = actual
  actual.start_with?(*@prefixes)
rescue NoMethodError
  false
end

#negated_failure_messageObject



276
277
278
# File 'lib/smartest/matchers.rb', line 276

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