Class: Minicrest::EndsWith

Inherits:
StringMatcher show all
Defined in:
lib/minicrest/ends_with.rb

Overview

Matcher that checks if a string ends with a given suffix.

Examples:

Basic usage

ends_with("world").matches?("hello world")  # => true
ends_with("hello").matches?("hello world")  # => false

See Also:

Instance Method Summary collapse

Methods inherited from StringMatcher

#description, #failure_message, #matches?, #negated_failure_message

Methods inherited from Matcher

#&, #description, #failure_message, #matches?, #negated_failure_message, #|

Constructor Details

#initialize(suffix) ⇒ EndsWith

Creates a new ends_with matcher.

Parameters:

  • suffix (String)

    the expected suffix



16
17
18
# File 'lib/minicrest/ends_with.rb', line 16

def initialize(suffix)
  super(suffix, :end_with?, 'end with')
end