Class: Minicrest::StartsWith

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

Overview

Matcher that checks if a string starts with a given prefix.

Examples:

Basic usage

starts_with("hello").matches?("hello world")  # => true
starts_with("world").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(prefix) ⇒ StartsWith

Creates a new starts_with matcher.

Parameters:

  • prefix (String)

    the expected prefix



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

def initialize(prefix)
  super(prefix, :start_with?, 'start with')
end