Class: Smartest::StartWithMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(*prefixes) ⇒ StartWithMatcher

Returns a new instance of StartWithMatcher.



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

def initialize(*prefixes)
  @prefixes = prefixes
end

Instance Method Details

#descriptionObject



125
126
127
# File 'lib/smartest/matchers.rb', line 125

def description
  "start with #{expected_description}"
end

#failure_messageObject



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

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#negated_failure_messageObject



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

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