Class: BaconExpect::Matcher::EndWith

Inherits:
Object
  • Object
show all
Defined in:
lib/bacon-expect/matchers/end_with.rb

Instance Method Summary collapse

Constructor Details

#initialize(end_string) ⇒ EndWith

Returns a new instance of EndWith.



3
4
5
# File 'lib/bacon-expect/matchers/end_with.rb', line 3

def initialize(end_string)
  @end_string = end_string
end

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



11
12
13
# File 'lib/bacon-expect/matchers/end_with.rb', line 11

def fail!(subject, negated)
  raise FailedExpectation.new(FailMessageRenderer.message_for_end_with(negated, subject, @end_string))
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/bacon-expect/matchers/end_with.rb', line 7

def matches?(subject)
  subject[-@end_string.size..-1] == @end_string
end