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.



78
79
80
# File 'lib/smartest/matchers.rb', line 78

def initialize(*prefixes)
  @prefixes = prefixes
end

Instance Method Details

#failure_messageObject



89
90
91
# File 'lib/smartest/matchers.rb', line 89

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
# File 'lib/smartest/matchers.rb', line 82

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

#negated_failure_messageObject



93
94
95
# File 'lib/smartest/matchers.rb', line 93

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