Class: MotionSpec::Matcher::EndWith

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-spec/matcher/end_with.rb

Instance Method Summary collapse

Constructor Details

#initialize(end_string) ⇒ EndWith



5
6
7
# File 'lib/motion-spec/matcher/end_with.rb', line 5

def initialize(end_string)
  @end_string = end_string
end

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



13
14
15
16
17
18
19
# File 'lib/motion-spec/matcher/end_with.rb', line 13

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

#matches?(subject) ⇒ Boolean



9
10
11
# File 'lib/motion-spec/matcher/end_with.rb', line 9

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